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 pluginsRename the awstats.model.conf file and edit.
mv awstats.model.conf awstats.www.example.com.confSetting up the AWStats configuration.
LogFile="/home/#####/logs/access_log-%YYYY-0-%MM-0-%DD-0-%HH-10.processed"
/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
DirData="."
KeepBackupOfHistoricFiles=1
SkipHosts="" SkipFiles=""
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]"
ShowLinksOnUrl=0
/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"
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