Thursday, 11 December 2008

Install AWStats

My home web server is a very quiet corner of the Internet and the last thing it needs is web stats. It goes without saying that I decided to install some.

Gettingsudo apt-get install awstats
Configuration

Using your favourite editor, create a file/etc/awstats/awstats.local.conf.

HostAliases="localhost 127.0.0.1"
LogFile="/var/log/apache2/access.log"
LogFormat=1
DNSLookup=1
DirData="/var/cache/awstats/"
DirCgi="/cgi-bin"
DirIcons="/icon"
SiteDomain="prawn.mine.nu"
AllowToUpdateStatsFromBrowser=0
AllowFullYearView=3
SkipHosts="REGEX[^127\.0] REGEX[^192\.168\.]"

I have configured mine to ignore any traffic on my subnet using SkipHosts parameter and a simple regex.

Create a directory /var/cache/awstatsmkdir /var/cache/awstats
chmod 700 /var/cache/awstats
chown www-data:www-data /var/cache/awstats

Next Step is copying the awstats icons to the relevant apache directory.sudo cp -r /usr/share/awstats/icon /var/www/icon
Testing the stats updatesudo /usr/lib/cgi-bin/awstats.pl -config=local -updateThe -config= parameter is the middle bit of your config filename. In this instance, the -config=local instructs the program to read the file /etc/awstats/awstats.local.conf.

Now you should be able to view your stats. Point your favourite browser at http://your.host.name/cgi-bin/awstats.pl?config=local and enjoy.

Scheduling updates


Set up crontab to run an update as often a you think sensible.sudo crontab -uroot -e
#mine looks something like this:
#update at 3 am
* 3 * * * /usr/lib/cgi-bin/awstats.pl -config=local \
-update

To admire the full glory of awstats and the lack of traffic on my home web server, here it is...

Further reading

You could do worse than the awstats sourceforge page and here for configuration directives.

No comments: