Westhost Tips and Tricks

This is a series of papers on working with Westhost servers. It only applies to you if you are a Westhost customer. Any additions, corrections, feedback: email 'wh @ gnomedia.com'.

I'm occasionally available for contract or consultation work, contact me via the gnome above if you have a request.

Read the introduction first, it contains important information and warnings!

Setting up AWStats (updated)

Advanced Web Statistics for your web site.

[This page is an update of an earlier document. The earlier version gave instructions on installing AWStats V5.9 and V6.0. Recently they released V6.4 and all users are urged to upgrade to that version, as earlier versions do have known security weaknesses.]

In a previous article on installing AWStats I gave detailed instructions on unpacking, installing and configuring AWStats. But, all this is now a lot simpler as the latest AWStats (V6.4) now has an installation script that takes care of some of the work for us. There are still some tweaks that need doing, but the process is very straightforward and only needs basic shell skills.

The main difference with this installation and the earlier versions that I described is that the earlier versions were installed in the existing web site, and this version is installed outside of the website and included by modifying the httpd.conf file to include it via an alias. I’ve left the installation the way that the script installs it, but there is no reason why you can’t modify it to install where you want.

Upgrading from an old installation.

First, note down the name that you used for the previous config file, for example: /etc/awstats.www.mydomain.com.conf and make a backup of the file (if installing in the same place).

Next, make a backup of the old statistics files:

$ tar cvzf ~/awstats-logs-backup.tgz /var/www/cgi-bin/awstats/*

For installing on mydomain.com

Make a backup of the httpd.conf file

$ cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.awbak

as this will be modified by the installation routine.

Download the package

$ cd
$ lynx http://prdownloads.sourceforge.net/awstats/awstats-6.4.tgz

and follow the instructions to download it.

Unpack the package

$ cd /usr/local/
$ tar xzf ~/awstats-6.4.tgz

Make a user friendly name for the directory and enter it

$ mv awstats-6.4 awstats
$ cd awstats

Make a directory to store the stats in

$ mkdir /var/lib/awstats

and run the configuration tool

$ tools/awstats_configure.pl

When asked to create a new config file, say yes. If upgrading, when asked for a name of the web site, use the name that was used before. Other questions, accept defaults.

Now make some final edit to the config file

$ vim /etc/awstats/awstats.www.domain.com.conf
# and change the following:
LogFile="/var/log/httpd/access_log"
HostAliases= if there are any aliases

Restart apache

$ restart
# or /etc/rc.d/init.d/httpd restart
# on older setups

If upgrading, copy over the old files

$ cp /var/www/cgi-bin/awstats/* /var/lib/awstats/

And, run an update…

$/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.domain.com

Assuming there was no error you should now be able to see the stats by pointing your web browser at:

http://www.domain.com/awstats/awstats.pl?conf=www.domain.com

Finally, we need to secure the installation against prying eyes by adding an .htaccess file to the script directory. And changing the /etc/httpd/conf/httpd.conf file and changing AllowOverride None to AllowOverride All in the awstats section, then restart Apache.

# .htaccess:
$ cd /usr/local/awstats/wwwroot/cgi-bin/
$ htpasswd -c .htpasswd username
$ vim .htaccess
    # -- .htaccess
    AuthName "Stats Login"
    AuthType Basic
    AuthUserFile ./.htpasswd
    require valid-user
    # -- end .htaccess

Now remove all the old awstats files from:

/var/www/cgi-bin/awstats.pl
/var/www/cgi-bin/awredir.pl
/var/www/cgi-bin/awstats/*
/var/www/cgi-bin/awtools/*

And, finally, update the cron tab with the new path to the script.

And that is it!

Let me know if I’ve forgotten anything, and as I said before, I recommend everyone using an older version of AWStats to upgrade to the latest version, as it is more accurate, better looking and more secure.