Best free web server log file analysis program

Q We have got a dedicated server and are running multiple Apache virtual hosts. I would like to produce some simple statistics for each of the virtual hosts without having to buy an expensive statistics package that not all of our customers will need. Is there a way to add this without additional cost?

A You're in luck: there's a free web server log file analysis program called Webalizer (http://webalizer.org), which you can use to generate detailed usage reports in HTML. The first thing to do is set up Apache so that each virtual host creates its own log files:

CustomLog logs/domain.co.uk-access_log common

The next step is to set up Webalizer to analyse each of the log files and generate individual reports. Create a central directory for your configuration files with mkdir -p /etc/webalizer/vhosts. Copy the /etc/webalizer.conf configuration file to /etc/webalizer/vhosts/ for each virtual host. Give the file the same name as the domain and end it with a .conf extension so you can easily tell what host the configuration is for. (For example, for domain.co.uk the file will be called /etc/webalizer/vhosts/domain.co.uk.conf.) The file will need to be edited - you should have at least the HostName, OutputDir and LogFile configuration directives set to something appropriate. You'll probably also want to specify other settings that are specific to a domain, such as HideReferrer, HideSite and maybe others as well. More information can be found in the man page (man webalizer). It should look like this:

LogFile /var/log/httpd/domain.co.uk-access_log
OutputDir /var/www/vhosts/domain.co.uk/usage
HostName domain.co.uk

Now, in order to process the logs for all your sites you need a simple script that you can just drop into /etc/cron.daily to be run once a day:

#!/bin/sh
for i in /etc/webalizer/vhosts/*.conf;
do /usr/bin/webalizer -c $i; done

Once this has been set up, all you need to do to add a new host is creat a new configuration file and put it in the central directory. It will automatically be picked up the next time the command is run KC

Follow us on Identi.ca or Twitter

Username:   Password:
Create Account | About TuxRadar