Website Traffic Statistics for Multiple virtual Hosts

This article of mine is dedicated towards the log processing for multiple virtual hosts (Name Based Sites). As we know almost every hosting server is having at least one hosting control panel installed on it, to control hosting services. Which will make all the jobs easy for maintaining each site on the server, including the per site based logging. But what if there is no control panel on the server and site owner is demanding for individual traffic statistics of its site.
There are different ways of doing that, but simplest one is configuring webalizer for multiple virtual hos. Let us design a simple scenario to proceed:
Assume that we have some virtual hosts (Name based sites)
1. with server access log file /var/log/httpd/access_log_alpha
2. with server access log file /var/log/httpd/access_log_beta
3. with server access log file /var/log/httpd/access_log_gama
and required is the individual traffic statistics for all these sites.
Create a centralized folder for webalizer configuration
# mkdir /etc/webalizer
Create individual webalizer configuration files for each site using sample configuration file
# cp /etc/webalizer.conf /etc/webalizer/
# cp /etc/webalizer.conf /etc/webalizer/
# cp /etc/webalizer.conf /etc/webalizer/
Now create individual directories for usage for each site
# mkdir -p /var/www/usage/{alpha,beta,gama}
Modify individual webalizer configuration file for each site, for example:
LogFile /var/log/httpd/access_log_alpha
OutputDir /var/www/usage/alpha
Similarly modify files for the other sites.
Run the following command to process webalizer statistics for each site
# webalizer -c
# webalizer -c
# webalizer -c
Required output will be in
/var/www/usage/alpha for
/var/www/usage/beta for
/var/www/usage/gama for
You can simplify this task if you are having large number of sites on your server
Write a small script named
# vi
for x in /etc/webalizer/*.conf
webalizer -c $x
required you should have configured webalizer configuration file for each virtual host.
Now you have to provide the URL to website owner by making soft link of usage directory in the DocumentRoot of that particular site.
For example: For, DocumentRoot is /var/www/html/
# ln -s /var/www/usage/alpha /var/www/html/
So the usage URL is
Do it for other virtual hosts accordingly.


Leave a Reply

Your email address will not be published. Required fields are marked *

five × 5 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>