Posted in Technology

How to configure Awstats web statistics for multiple sites managed by one Apache server

Awstats is a web traffic analytics software package that collects statistical data about visitors of a web site. It inserts data into a database so that it is easy to view historical statistics and compare it to today’s numbers. A web server, such as Apache, continuously writes log files that Awstats reads and where it extracts the data.

Awstats can analyze web, email, and ftp server data. Statistics for the number of visitors, most visited pages, referrers, search engines, browser apps, keywords, and other information is displayed on a dashboard.

Our earlier article explains how to install and configure Awstats for a web site, such as WordPress, Drupal or for another site, but now, I will guide you through the process of configuring Awstats for a server that runs multiple web sites. A quite typical setup for a web server powered by Apache is to configure it to manage multiple web sites. Apache calls them virtual hosts. If you want to separate statistics for each virtual host, Awstats can do it, but it requires a little bit of configuration.

Assuming you already have Awstats running and generating statistics for a web site, here are the steps you have to take to make it work for multiple virtual hosts.

The guide has been tested on Debian 8 (Jessie) and Debian 10 (Buster) with Apache 2.4.

Let’s say you have two sites: myblog.com and anothersite.net.

Open the Apache virtual host configuration file /etc/apache2/sites-available/myblog.conf
(myblog is your conf file name, often it is the same as the domain name) and modify the log entry:
CustomLog ${APACHE_LOG_DIR}/access.log combined
into:
CustomLog ${APACHE_LOG_DIR}/access-myblog.log combined

Do the same for the anothersite.net Apache virtual host file. Create a unique log file name so that Awstats can separate each web site’s data.

Make a copy of the Awstats configuration file for each site:
cp /etc/awstats/awstats.conf /etc/awstats/awstats.myblog.com.conf
cp /etc/awstats/awstats.conf /etc/awstats/awstats.anothersite.net.conf

(replace myblog.com and anothersite.net with your actual domain names)

Edit the file awstats.myblog.com.conf as follows (these are the default values that usually work):

LogFile="/var/log/apache2/access-myblog.log"
LogFormat=1
SiteDomain="myblog.com"
HostAliases="www.myblog.com myblog.com"
DNSLookup=0
AllowFullYearView=3
LoadPlugin="tooltips"
LoadPlugin="geoipfree"
(you may have to install additional software for this to work – it shows country names instead of numbers)

Edit awstats.anothersite.net.conf as well, making sure that the log file name and domain name reflect this particular site.

That’s it for setting up Awstats so that it can collect statistics for multiple virtual hosts managed by one Apache server. All the other configuration settings for each site, such as access rights must be tweaked as explained in the guide that explains the steps required for configuring Awstats for a single web site.



Leave a Reply

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


CAPTCHA Image