April 17, 2006

437 words 3 mins read


Recently I ‘discovered’ AWStats. It wasn’t that I didn’t know about it, I just never bothered to try it. I had webalizer, I liked it, no reason to switch. Reglardless, since the server switch, I tired out AWStats, and I have to say its rather nifty.

Now in my setup, I have to handle a number of different domains. With webalizer its one config per domain, generated into one directory per domain. With AWStats, you need different configs, but you can have all the same AWStats.pl file for each one. First thing first, Installing AWStats. Its debian so apt-get install awstats did the job. Second, setting up apache. While I have a number of virtual host directives, I wanted the same aliases to apply everywhere. So outside all configs I have:


Alias /awbin/ /usr/lib/cgi-bin/

Alias /aw-js/ /var/aw-js/

Alias /awstats-icon/ /usr/share/awstats/icon/


The aw-js director is for the javascript to do detection of browser capabilities. There’s a bit in the config file, read about it there. The next thing I did was setup configs for each domain. Setting them up is simple. Simply create a file named awstats.yourdomainhere.com.conf. I wanted all the domains to be setup the same, so the domain specific file (just created) only has the following four lines:





Include “/etc/awstats/awstats.conf.local”_

Everything else was in awstats.conf.local, which I copied from awstats.conf and just dropped the 4 configs listed above. (Also make sure to drop the include at the bottom of that file or perl will go nuts cause your re-including the same file over and over). You then need to run /usr/lib/cgi-bin/awstats.pl -update -config=yourdomain.com. This will read the config file and run the initial proccess of log files. If that works and you can goto yourdomain.com/awbin/awstats.pl (or what ever you setup) and your log info shows up — then you just need to setup a cronjob. I personally have (per domain): 5 * * * * www-data /usr/lib/cgi-bin/awstats.pl -update -config=yourdomain.com >/dev/null . None of the sites I host are SUPER busy, so doing the proccess once and hour works fine. You could probably have it proccess as short as once every 5 mn, if you wanted to. So far it doesnt seem to bog my machine down. I realize there are better ways of setting up the cronjob, so that it auto-reads every file in the directory — but I’m lazy and this way gives me more granular control.

AWStats for Snowulf

If all goes well, you get something that looks like the picture on the right. You can even fiddle with putting extra addins, like GeoIP, which is really sweet.