apt-get install awstats

copy configuration files and cached data (old statistics) from old machine (the
cached data will have to be copied once again exactly before moving to

mkdir /var/cache/awstats
ln -s /usr/share/doc/awstats/examples/
apt-get install libgeo-ipfree-perl libgeo-ip-perl geoip-bin
#(required for the geoip plugin for awstats)

Build the stats files using:

$AWSTATS -update -dir=/data/www/data/analyze/awstats -awstatsprog=$AWSTATS

Not so simple

At first everything seemed ok and I was even dumb enough to not check the results in detail but after a while I realized they did not worked:

Error Opening file GeoIP.dat....Can't call method "country_code_by_addr" on an undefined value at /usr/share/awstats/plugins/ line 96, <LOG> line 2.

I decided to do a small program of my own to check


use Geo::IP;
my $gi = Geo::IP->open(“/usr/share/GeoIP/GeoIP.dat”, GEOIP_STANDARD);
print $gi->country_code_by_addr(“”);

This worked so finally I modified the /usr/share/awstats/plugins/ file:

if (! $datafile) { $datafile="/usr/share/GeoIP/GeoIP.dat"; }
if (! $datafile) { $datafile="GeoIP.dat"; }

One Response

  1. Maybe you didn’t load the geoip plugin with the correct 2 parameters (mode and path to GeoIP.dat). See the description of the GeoIP plugin at

Leave a Reply