Wednesday, June 2, 2010

Install Awstats on Ubuntu

SkyHi @ Wednesday, June 02, 2010

This has been tested with Ubuntu server 8.04 (Hardy Heron).


sudo aptitude install awstats

To see the country of your visitors (not required)

sudo aptitude install libnet-ip-perl
sudo aptitude install libgeo-ipfree-perl


Let's assume you want to analyze the Apache 2 log file of your website “” (It can be just an IP address).

Create configuration file

sudo cp /etc/awstats/awstats.conf /etc/awstats/

Update these parameters

# apache2

# domain name


You can also activate these plugins



sudo /usr/lib/cgi-bin/ -update

You should get something like this

Create/Update database for config "/etc/awstats/" by AWStats version 6.7 (build 1.892)
From data in log file "/var/log/apache2/access.log"...
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)...
Jumped lines in file: 0
Parsed lines in file: 191338
Found 0 dropped records,
Found 24 corrupted records,
Found 0 old records,
Found 191314 new qualified records.

Configure Apache to view the statistics

Create /etc/apache2/conf.d/statistics

Alias /awstatsclasses "/usr/share/awstats/lib/"
Alias /awstats-icon/ "/usr/share/awstats/icon/"
Alias /awstatscss "/usr/share/doc/awstats/examples/css"
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
ScriptAlias /statistics/ /usr/lib/cgi-bin/
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch

Restart Apache

sudo /etc/init.d/apache2 restart

View your statistics

or (in case you have more than one config file)

Update your statistics with cron

In /etc/crontab add

# update every 10 min
*/10 * * * * root /usr/lib/cgi-bin/ -update > /dev/null

How to reset awstats

Just delete the files in /var/lib/awtstats (directory defined by DirData parameter)

sudo su - root
cd /var/lib/awstats
rm *


  • you have to be root because for some reason, sudo rm -R awstats/* wouldn't work.
  • if you get the message Never updated (See 'Build/Update' on awstats_setup.html page) whereas the awstats files are there in /var/lib/awtstats, it's probably a permission problem on this folder.



awstats "Error: SiteDomain parameter not defined in your config/domain file. You must edit it for using this version of AWStats. "

Try to this URL (with your values):