AWStats - web log analyser
I wanted an easy way to monitor web visit statistics on my low traffic website. I looked around and found AWStats and Webalizer. Here’s a comparion of different log analyers, mind it’s hosted by AWStats. Nonetheless AWStats seems to be preferred from user posts on forums for it is said to be more accurate and offers more features.
awstats is available as a debian package, however the file structure is different from the default and the difference is not documented so I had a bit of searching to do before I could configure it. I proceeded as follows:
$ mv /usr/share/doc/awstats/examples/ /usr/local/awstats $ cd /usr/local/awstats $ gunzip awstats.model.conf.gz $ mkdir wwwroot; mkdir wwwroot/cgi-bin $ mv awstats.model.conf wwwroot/cgi-bin $ ./awstats_configure.pl
The configure script modifies httpd.conf to include Alias and directives for awstats directories. However the directories are not where they should be. So we can either change these Aliases in httpd.conf to point to what the directories actually exist, or we could link it to where it should be. I choose the latter.
$ ln -s /usr/local/awstats/css/ wwwroot/ $ ln -s /usr/share/awstats/* wwwroot/ $ ln -s /usr/lib/cgi-bin/awstats.pl wwwroot/cgi-bin/ $ chown -R --dereference www-data:www-data wwwroot $ chown -R www-data:www-data /var/lib/awstats/ $ chown root:www-data /var/log/apache/access.log
Since it’s symlinked, we need to allow symlinks in the wwwroot directive in the apache config file. Optionally if we want to access it remotely from the web, we also need to configure htaccess for awstats.
<Directory "/usr/local/awstats/wwwroot">
Options FollowSymLinks # add this
AllowOverride None
Order allow,deny
Allow from all
# include this to enable password protected htaccess
AuthType Basic
AuthName "Password Required"
AuthUserFile /usr/local/apache/passwd/passwords
Require user anniec
<Directory>
Restart apache,
$ apachectl graceful
One more thing about permissions. The apache logfile is archived and recreated every week, so in order to allow awstats to have read access to the fresh log file we need to modify the log rotation script,
/var/log/apache/*.log {
...
# change "create 640 root admin" to
create 640 root www-data
Now we finally come to configuring awstats in awstats.frasco.hopto.org.conf, substitute frasco.hopto.org with your domain name.
LogFile="/var/log/apache/access.log" # the following setting parses all logs including old gzipped archive logs #LogFile="/usr/local/awstats/logresolvemerge.pl /var/log/apache/access.log* |" LogType=W LogFormat=1 SiteDomain="frasco.hopto.org" DNSLookup=1 DirData="/var/lib/awstats" AllowToUpdateStatsFromBrowser=1 # need to make DirData writable by www-data if set to 1 AllowAccessFromWebToAuthenticatedUsersOnly=1 # need to configure .htaccess if set to 1 AllowToUpdateStatsFromBrowser=1
The debian package also comes with a cron file, but need to be modified to point to the right awstats.conf file, e.g.
0,10,20,30,40,50 * * * * www-data /usr/lib/cgi-bin/awstats.pl -config=frasco.hopto.org -update >/dev/null
or if you have multiple config files:
0,10,20,30,40,50 * * * * www-data /usr/local/awstats/awstats_updateall.pl now -update >/dev/null
Try running it manually:
$ /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=frasco.hopto.org
If all goes well we should be able to access it from the browser on http://localhost/awstats/awstats.pl?config=frasco.hopto.org.
4 Responses to “AWStats - web log analyser”
Leave a Reply
You must be logged in to post a comment.
October 29th, 2004 at 6:01 am
Just wanted to tell you thanks for the info. Because of the info on your page, I was able to get awstats up and running in about 20 Minutes.
Thanks again!
November 5th, 2004 at 11:24 am
Note: If you you are hosting multiple sites on your server (IP based or virtual hosting) and want individual (not all lumped together) stats you will need to modify your apache config to create a seperate log for each site that you host.
Once that is complete follow the setup mentioned above and point the config for each site to the logfile for each site.
Thanks for posting these directions!
Sam
April 16th, 2005 at 11:55 am
Hi,
Thanks for the guide. Got me up and running in no time!
Rob.
November 30th, 2006 at 12:45 am
Excellent post.