Setting up AWStats on the Media Temple (gs) Grid-Service

The tricky things about setting up AWStats on the Media Temple Grid-Service are that you only have one access log for all your sites, the page requests always have the domain name prepended to them, the logs are processed by Media Temple and then renamed to reflect when the processing is complete, and there is a delay in the processing of these logs which isn't always consistent. These factors have to be accounted for when you setup the AWStats configuration.

Start from the home directory of your (gs) account. Download and decompress the latest stable copy of AWStats.

wget "http://prdownloads.sourceforge.net/awstats/awstats-6.9.tar.gz"
tar zxf awstats-6.9.tar.gz

We'll be setting up AWStats to run as a cgi script, so the files in the cgi-bin directory in the awstats folder will be moved into the cgi-bin directory of the domain we are setting up the statistics for.

cd awstats-6.9/wwwroot/
rsync -az cgi-bin/ ../../domains/example.com/cgi-bin
cd ../../domains/example.com/cgi-bin

You should now see the following files and folders in the cgi-bin directory of the site you are setting up AWStats for.

$ ls
awredir.pl  awstats.model.conf  awstats.pl  lang  lib  plugins

Rename the awstats.model.conf file and edit.

mv awstats.model.conf awstats.www.example.com.conf

Setting up the AWStats configuration.

LogFile="/home/#####/logs/access_log-%YYYY-0-%MM-0-%DD-0-%HH-10.processed"
This directive tells AWStats to parse the log file that was marked as processed on the grid 10 hours ago. A new log file is created every hour in /home/#####/logs so you will want to set up a cron job to run AWStats every hour. I've found that a 10 hour delay is sufficient for my sites.

SiteDomain="www.example.com"
HostAliases="www.example.com localhost 127.0.0.1"

DNSLookup=1
Not necessarily required.

DirData="."
By default the AWStats data is saved in the directory where the script is, most likely you will want to change this.

KeepBackupOfHistoricFiles=1
I find it a good idea to enable this option.

SkipHosts=""
SkipFiles=""
There are probably some hosts and files you will want excluded from your statistics gathering, they would be entered here following the examples shown before each directive in the config file. Keep in mind that because of the way Media Temple does the logging on the grid if you wanted to skip counting the file page.html you would have to enter it as /example.com/page.html.

This next directive is needed if you have AWStats set up for multiple domains on one gs grid account.

OnlyFiles="REGEX[example.com]"
Since every page request gets logged with the domain prepended having this line in each AWStats config file will let you gather statistics for multiple domains within one gs account.

ShowLinksOnUrl=0
Since the links will appear as /example.com/page.html they won't be valid links from the AWStats pages so best to set this to 0.

That is all that is needed for the basic setup, now is a good time to try to generate a first set of data from the command line.

From the cgi-bin directory the command would be

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

This should run without error and if there are any qualified records the data files will be created.

The statistics can then be viewed from a web browser with

http://www.example.com/cgi-bin/awstats.pl?config=www.example.com

The AWStats pages can be customized by adding your own icon

Logo="your_logo.png"
LogoLink="http://www.example.com"

The file your_logo.png then needs to be in the icon/other directory and this icon directory should be moved to the document root as all the needed AWStats graphics are located there as well. You can also adjust this if needed with the

DirIcons="/icon"
directive.

Setting up the GeoIP Plugin.

To get the GeoIP plugin working the Perl module Geo::IP::PurePerl is needed. Here are the steps to install:

cd
mkdir temp
cd temp
wget "http://geolite.maxmind.com/download/geoip/api/pureperl/Geo-IP-PurePerl-1.23.tar.gz"
tar zxf Geo-IP-PurePerl-1.23.tar.gz 
cd Geo-IP-PurePerl-1.23/
rsync -a lib/Geo /home/#####/users/.home/domains/example.com/cgi-bin/plugins

Two free GeoIP databases are needed. I'll put these in the Geo folder but they can go anywhere that makes sense, the paths then have to be specified in the AWStats config.

cd /home/#####/users/.home/domains/example.com/cgi-bin/plugins/Geo
wget "http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz"
gunzip GeoIP.dat.gz
wget "http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz"
gunzip GeoLiteCity.dat.gz

Then update the AWStats config
LoadPlugin="geoip GEOIP_STANDARD /home/#####/users/.home/domains/example.com/cgi-bin/plugins/Geo/GeoIP.dat"
 
LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /home/#####/users/.home/domains/example.com/cgi-bin/plugins/Geo/GeoLiteCity.dat"

The GeoIP databases are updated the first of every month. So the wget and gunzip commands above can be put into a script and setup as a monthly cron, something like

#!/bin/bash
 
cd /home/#####/users/.home/domains/example.com/cgi-bin/plugins/Geo
wget -N -q "http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz"
gunzip -f GeoIP.dat.gz 
wget -N -q "http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz"
gunzip -f GeoLiteCity.dat.gz 

And that's it.

Comments

Seperating out each domain

I really wanted separate stats per each domain and couldn't find any good tutorials on it. I talked with support and hacked around for a while and came up with the following:

http://penguindreams.org/blog/installing-awstats-on-a-media-temple-grid-server-gs/

There is a python script I use in there in combination with the awstats log merging tool that works really well. Check it out.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <em> <strong> <cite> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Textual smileys will be replaced with graphical ones.

More information about formatting options