Why? #

because server stats are important… #

The quality of your website also happens to depend on the number of mistakes they have. A professional website is supposed to have less dead links for example. Search engines use information like this to rank your site. It is also good to know which specific pages are the most frequently visited on your site:

  • optimize your content to fit the expectations of your audience
  • never ever delete a page which is frequently visited, also known as the Cool URIs don't change-rule.

and compared to other tools… #

Compared to the popular and fast webalizer, which is written in C and requires little dependencies awstats has a few advantages:

  • displays a list of error 404: file not found, so it can be used to locate dead links (my personal killer feature in this comparison)
  • is written in perl and is expandable via perl modules. Perl is a good choice since regular expressions are a language feature and can easily be used
  • looks nicer and can be further tweaked by using plugins
  • better maintained

How? #

Under FreeBSD files are typically located under /usr/local/www/awstats/. Depending on the webserver you use this location does not really matter when aliases are used.

Configuration #

A minimalistic configuration might look like this...

step 1
Take the model file as an example for an configuration and cusomize the following 5-6 lines:
# /usr/local/www/awstats/cgi-bin/awstats.model.conf
and save the file the file in that cgi-bin-folder and under a new name, but use the form awstats.[].conf or it will not work.
step 2
create the directory for incrementall data (that way the stats can be updated more quickly):
  mkdir /usr/local/www/logs/
  chown www:www /usr/local/www/logs/
step 3 (optional)

visit your stats and update them

visit []/awstats/[]. That way you can use one installation to log all your subdomains for example by providing a config file for each of those.

step 4 (optional)

use a cron job to update your stats

# update all stats...
/usr/local/www/awstats/tools/ -awstatsprog=/usr/local/www/awstats/cgi-bin/ -configdir=/usr/local/www/awstats/cgi-bin/ now

and restart cron with /etc/rc.d/cron restart

Troubleshooting #

No stats: Every digit is a 0

This has propably to do with the LogFormat you specified. It is annoying, but is has to match exactly the number of fields per line

Execute /usr/local/www/awstats/cgi-bin/ from the shell and see what it says.

Known log formats #

LogFile="/usr/local/bin/perl /usr/local/www/awstats/tools/ /usr/local/var/log/* |"
LogFormat="%host %other %logname %time1 %methodurl %code %bytesd %virtualname %refererquot %uaquot %other"