• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Michele Neylon :: Pensieri

Michele Neylon :: Pensieri

Technology, Marketing, Domains, Thoughts

Configuring Awstats with Apache 2 on Ubuntu

August 3, 2005 by Michele Neylon 25 Comments

Being able to track your web statistics is important for commercial sites. For personal sites it may not be as important, but it still nice to know where people are coming from and what they are looking for.
There are a number of open source log analysers that work with Apache, however my preferred choice is Awstats.



It may not be able to give the same level of detail as a commercial package such as Urchin, but it provides more than enough detail for most purposes.
On Ubuntu you can install awstats via apt:
apt-get install awstats
This will install the base package however, if you want to lever its full power you will need to install a couple of extra Perl modules.
apt-get install libnet-ip-perl
If you would like to see which countries your visitors are based in then you should look at one of the IP to Country plugins which will give you a Geo IP lookup.
You can choose between either geoipfree or GeoIp.
Other useful plugins are:

  • Plugin: HostInfo – which gives you a popup whois window
  • Plugin: IPv6 – adds IPv6 support
  • Plugin: Tooltips – confused by all the information? This will take away the mystery πŸ™‚

On rpm-based system there is a handy little perl script that walks you through the initial configuration. On Ubuntu you have to do it by hand, however most of the configuration is self-explanatory.
Simply copy the provided sample config to a new config file:
cp awstats.conf awstats.yoursite.tld.conf
NB: You will need a separate configuration file for each vhost you wish to examine.
Edit the conf file to match your site’s setup. Important things to pay attention to are any domain aliases, the location of the log files and any IPs you wish to ignore (eg. your own)
You can also decide which optional plugins you want to load. Simply add a line to invoke each one:
LoadPlugin="geoipfree"
LoadPlugin="ipv6"
LoadPlugin="Tooltips"

geoipfree requires an extra perl module. On ubuntu the package is called libgeo-ipfree-perl
You are almost ready!
You now need to configure Apache to allow access to your awstats pages.
Rather than messing about with my main Apache config file I found it neater to place the awstats specific information in an external file called awstats.conf:

Options None
AllowOverride None
Order allow,deny
Allow from all

Alias /awstatsicons/ /usr/share/awstats/icon/
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all


Then use an include directive in your main Apache config (apache2.conf):
Include /etc/apache2/awstats.conf
You then need to add it in to your vhost:
ScriptAlias /whereyouwanttoaccessit/ /usr/lib/cgi-bin/
If you navigate to:

http://www.yourdomain.tld/whereyouwanttoaccessit/awstats.pl?config=yourdomain.tld

You *should* be able to access your stats.
Of course you’ll need to actually generate the stats first:
/usr/lib/cgi-bin/awstats.pl -config=yourdomain.tld -update
I would recommend you run this from the command line once to create the first set of stats and then add a cronjob:
crontab -e
0,10,20,30,40,50 * * * * /usr/lib/cgi-bin/awstats.pl -config=yourdomain.tld -update >/dev/null
wq

This will update your stats every 10 minutes, which means that you’ll only have to update a few lines at a time. If your site is busy this makes sense πŸ™‚
The last part of the line is important:
>/dev/null
By default cron emails the user each time it runs. You really don’t want 6 emails an hour telling you that Awstats has run πŸ™‚
NB: This works for me. Your mileage may vary. If I’ve left out anything blatantly obvious please let me know
Apache Pocket Reference

Related Posts:

  • computer-code-screens
    Dodgy WordPress Developer Tactics
  • privacy-keyboard-keys
    My Privacy Has Been Sold
  • Photo of old hand written letters on a desk with some pencils and pens
    I Sometimes Yearn For Simpler Times
  • ACDC-Dublin-Ticketmaster-Q
    The "Joys" of Acquiring Concert Tickets
  • rhubarb-strawberry-crumble
    Enjoying the Harvest From my Garden Already
  • Video thumbnail for youtube video khocvrulvkk
    Starburster Fontaines DC

Filed Under: Open Source, Techie :: Techno ::

Michele is founder and CEO of Irish hosting provider and domain name registrar Blacknight. Read More…

Reader Interactions

Comments

  1. Bernhard says

    January 11, 2006 at 10:19 am

    Hi Michelle
    why didn’t you put awstats into /etc/apache2/conf.d? Then it is included automatically …

  2. blacknight says

    January 11, 2006 at 1:35 pm

    Bernhard
    The way I set it up it works πŸ™‚
    Michele

  3. David says

    January 14, 2006 at 1:36 am

    I see that you configuration does not show up properly in the blog.
    The tags are completely missing (seems your blog cleans those from your postings).
    Also I put this line:
    Alias /awstats-icon/ /usr/share/awstats/icon/
    instead of:
    Alias /awstatsicons/ /usr/share/awstats/icon/
    otherwise icons don’t show up for me.

  4. roger says

    February 28, 2006 at 10:16 am

    I played around with icon settings too. It just needs to match with the value in the config file.
    DirIcons=”/awstats-icons” is the default.
    And the config file only needs to match your config parameter, not you host or domain. For example, I can create a config file /etc/awstats./conf. I just need to put config= everywhere.

  5. roger says

    February 28, 2006 at 10:18 am

    lets repeat the last part:
    For example, I can create a config file /etc/awstats.whatever.conf. I just need to put config=whatever everywhere.

  6. Zsolt says

    April 3, 2006 at 10:26 pm

    Thx Michele!
    With the help od your little HowTo it was an easy task to set up Awstats on my server….
    Even dough I use Debian ^^.
    @ David If you wouldn’t have mentioned it, I would have never taken a closer look to this blogs page source, and probably would have missed the Directory tags…
    Thank you too…
    Zsolt

  7. Brad says

    April 16, 2006 at 4:53 pm

    works great!
    One note however, for the tooltips plugin, the plugin name is a lower case t. You will get an error if you use:
    LoadPlugin=”Tooltips”
    use
    LoadPlugin=”tooltips”
    instead!

  8. Seb says

    April 27, 2006 at 11:05 pm

    I have a problem:
    even if awstats woked for a few good months, it stoped working.
    not sure hy, but probably after a update or something on Ubuntu, awstats report the error:
    Not Found
    The requested URL /cgi-bin/awstats.pl was not found on this server.
    Do you have any idea where to look for a solution?

  9. michele says

    April 27, 2006 at 11:55 pm

    Seb – Sounds like your apache configuration has changed. You may have overwritten one of the configuration files during an upgrade

  10. Seb says

    April 28, 2006 at 12:05 am

    Michele,
    yes, this is true and I fixed teh problem, adding ScriptAlist to cgi-bin
    however now I see a diff problem, and this is related to the fact that there are no records in /var/log/apache2/access.log file.
    This is also since my last upgrade – I see access.log file unchanged since my upgrade.
    But can’t figure out why as the apache2.conf file has the LogFormat entryes.

  11. Daniel says

    January 5, 2007 at 8:22 pm

    Michele, my Ubuntu package already provided a /etc/cron.d/awstats config file? It’s different from the one you typed.

  12. michele says

    January 5, 2007 at 8:28 pm

    Daniel
    Which version of Ubuntu and Awstats are you using?
    What’s in the config file?
    Michele

  13. Daniel says

    January 5, 2007 at 8:50 pm

    I’m using the awstats 6.5 on Dapper.
    0,10,20,30,40,50 * * * * www-data [ -x /usr/lib/cgi-bin/awstats.pl -a -f /etc/awstats/awstats.conf -a -r /var/log/apache/access.log ] && /usr/lib/cgi-bin/awstats.pl -config=awstats -update >/dev/null
    I’ve modified the -config entry to suit my website’s config. In your example it would be yourdomain.tld.
    Could you please look at what David has already mentioned? Your Apache config directives are treated as HTML instead of text.
    Try replacing ” with ‘>’.

  14. THG says

    January 8, 2007 at 8:33 pm

    Daniel,
    the code points to the /var/log/apache directory instead of /var/log/apache2/access.log

  15. Mathew says

    January 29, 2007 at 10:11 am

    Nice article, thanx. It was help me much…
    Is there any change if i have debian?

  16. Alex Robar says

    January 30, 2007 at 4:53 am

    Great article Michele. I just setup AWStats on Ubuntu 6.06 using your guide and it works great! Thanks for writing this.

  17. John Pye says

    March 13, 2007 at 10:49 am

    geoipfree says I’m in China. Which I’m not. I suspect its database is out of date enough not to be worth bothering with.

  18. Trond Egil says

    March 30, 2007 at 11:54 am

    Hello.
    Can I set ut an AWStats Server that reads Apache logs on another server ?
    How do I do this, as I can’t install AWStats on the Apache web server.

  19. michele says

    March 31, 2007 at 2:15 pm

    Trond
    I don’t think you could get it to read logs from a remote server “live”, but you could probably copy the logs across and do it that way. Of course someone else may know of a way of doing it
    Michele

  20. michele says

    March 31, 2007 at 2:15 pm

    @John
    The Maxmind DB works well
    If you need Geoip you will end up paying for an up to date one
    Michele

  21. Trond Egil says

    April 11, 2007 at 1:03 pm

    Hello.
    I can’t get icons to show.
    Can someone please show me how the /etc/awstats/awstats.conf file looks like.
    I get error every time Apache2 restarts.
    I have also tried to include everything in apache2.conf, but no luck.
    Please help me….

  22. gogan says

    April 28, 2007 at 12:20 am

    I’m trying to setup my apache2 on ubuntu breezy, I’ve followed your steps but I get this error when I ran
    /usr/lib/cgi-bin/awstats.pl -config=gogan.homelinux.org -update
    Error: Plugin load for plugin ‘geoip’ failed with return code: Error: Can’t locate Geo/IP/PurePerl.pm in @INC
    Thanks in advance

  23. michele says

    April 28, 2007 at 10:02 am

    Gogan – Have you installed the geoip module?

  24. neaveru says

    May 7, 2007 at 11:02 pm

    Gogan: I had the same issue. Try the following:
    sudo apt-get install libgeo-ipfree-perl
    Also, for crontab, instead of
    0,10,20,30,40,50 …
    You can replace it with:
    */10 …
    Cheers
    http://neaveru.blogspot.com

  25. neaveru says

    May 7, 2007 at 11:05 pm

    Sorry for the double post, just wanted to add for Trond Egil:
    To get icons to work, this worked for me, in my apache2.conf:
    Alias /awstats-icon/ /usr/share/awstats/icon/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

dotblog founder

Mastodon

Archives

  • Bluesky
  • Instagram
  • Threads
  • Twitter

Pages

  • About Me
  • About This Site
  • Archives
  • Comments Policy
  • Contact Me
  • Newsletter
  • Privacy

Blogroll

  • Paul Savage – BlackDog SEO
  • Blacknight Blog
  • Gianni Ponzi
  • Stewart Curry
  • Gordon Hudson

Stalking Links

Subscribe to Michele Neylon :: Pensieri

Blogroll

  • Blacknight Blog
  • Damien Mulley
  • Gianni Ponzi
  • Gordon Hudson
  • Grandad
  • My Mastodon
  • Paul Savage – BlackDog SEO
  • Stewart Curry
  • Technology.ie Podcast
  • Tom Doyle

Sites

  • Business Travel Tips
  • Discount Coupon Codes
  • Domain News
  • Fat.ie – my diet blog
  • Film Posters
  • Film Reviews
  • Films
  • Free Desktop Wallpapers
  • Irish Blogger Discussion Forum
  • Irish Stamps
  • Movie Trailers and News
  • Paste.ie

Footer

Site hosted in Ireland by Blacknight - Content copyright Michele Neylon

Copyright © 2025 Β· Magazine Pro on Genesis Framework Β· WordPress Β· Log in