AWstats Web Statistics Multiple VirtualHosts

These instructions are for RedHat but I am sure they can be teaked as appropriate for other Linux distros.

In addition, a better approach for multiple VirtualHosts can be found here including tweaking the log file format and additional scripts to automate the process: http://www.dotvoid.com/2005/01/awstats-with-virtual-hosts-on-apache/

Installation

1. Download awstats for your linux distribution.

2. Copy it to the server you want it installed (or do both in one step with wget if you know the URI)

3. Install the .rpm package: yum install awstats-*.noarc.rpm

Configure Apache

1. Add the following lines it the VirtualHost directive.

CustomLog logs/www.example.com_access_log combined
CustomLog logs/access_log combined

The second entry is the default access_log for Apache. I like to log to both files so I can have an awstats for the entire server and one just for the VirtualHost

2. Reload the Apache service.

Configure AWstats

1. Copy the awstats.model.conf to have a name with your VirtualHost name in it. Give the web service user read/write access to the newly created file.

cp awstats.model.conf awstats.www.example.com.conf

2. Open the newly created file and edit the SiteDomain, HostAliases, and DirData minimally in the config file.

3. Create the Data Directory and give Web service read/write permissions.

Generate the Data

1. You can run the awstats.pl command directly from command line to generate the data that is already in the access_log file.

/path/to/awstats.pl -update -config=www.example.com

This may take some time if the log file is pretty big.

2. Add the command to a crontab to have run for you automatically at a certain point every day or however often you would like.

View the web page

1. Now you can browse to the website to view the data.

http://www.example.com/awstats/awstats.pl

Repeat the above steps for each VirtualHost

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s