Smartlab Software logo

AWStats: Geo Usage

AWStats logo How to set up geography-related plug-ins for AWStats.

Steps

  1. Acquire AWStats, other programs, and pertinent information
  2. Install AWStats on the 1and1 shared server
  3. Install AWStats on your computer
  4. Set up the AWStats config file
  5. Create a usable log file
  6. Create/update the AWStats database
  7. Create a traffic web page
  8. Create report batch files
  9. Analyze the traffic page
  10. Tasks

Extending AWStats

  1. Extras
  2. Geographic Plug-ins
  3. How To

Help

  1. Glossary
  2. FAQ
  3. Pages not found FAQ
  4. Stop Referrer Spam

AWStats Geo

AWStats has several geography plug-in options. Country, region, city level. They are much faster than using a reverse DNS lookup though DNS lookup gives you a host name for the IP address if it can.

Windows

1. Install Geo::IP::PurePerl script which is used for country and city plug-ins. This depends on the version of Perl you have. To find the version of Perl, see the acquire tutorial step.

  • For 5.10.xx
    • from a command window type in:
      C:> ppm install http://trouchelle.com/ppm10/Geo-IP-PurePerl.ppd
    • this will install Geo::IP::PurePerl to your Perl.
    • You can find the current version by typing in:
      C:> ppm list
      and looking for geo-IP-PurePerl

Geo Country

  1. Download and install GeoIP.dat file from MaxMind into the geodb directory. This file is updated every month.
  2. In your AWStats config file, set LoadPlugin="geoip GEOIP_STANDARD PATH/geodb/GeoIP.dat"
    to point to your GeoIP.dat file.
  3. Here is a perl test script that tests the installation of Geo::IP::PurePerl and the GeoIP database. Save the file as test-geo-ip-pureperl.pl in the mytools directory then run it in a command window:
       perl  test-geo-ip-pureperl.pl
    The answer should be "United States"
use Geo::IP::PurePerl;
my $gi = Geo::IP::PurePerl->new(GEOIP_STANDARD);
print $gi->country_name_by_name("www.smartlabsoftware.com");

Geo City

  1. Download and install GeoIPCity.dat file from MaxMind into geodb. This file is updated every month.
  2. Update your AWStats config file by uncommenting (removing the #) and entering the full path to your GeoLiteCity.dat file.
    change LoadPlugin="geoip_city_maxmind GEOIP_STANDARD PATH/geodb/GeoLiteCity.dat"
  3. Here is a perl test script that tests the installation of Geo::IP::PurePerl and the GeoIP database. Save the file as test-city.pl in the mytools directory.
  4. Change the GeoLiteCity.dat data path
  5. Run it in a command window:
       perl  test-city.pl
    The answer depends but should be a city and a state if in the U.S.
use strict;
use Geo::IP::PurePerl;
my $gi = Geo::IP::PurePerl->open("d:/dev/aw/geodb/GeoLiteCity.dat",GEOIP_STANDARD);
my $addr = "www.smartlabsoftware.com";
print $gi->country_name_by_name($addr);
my @mydata = $gi->get_city_record($addr);
print "addr is in city: $mydata[4] and region: $mydata[3]";

Creating an automatic update script

This is a script that downloads the GeoIP.dat and GeoLiteCity.dat files, installs them, then deletes the compressed version. This script can be run monthly using Windows task manager. Change the LOCALPATH variable for yours.

1. Install wget for Windows in the mytools directory The install process creates a wget directory.

rem
rem Download geo databases for AWStats
rem
set LOCALPATH="d:\dev\aw"
rem
rem -S keep date of file modification
rem
"%LOCALPATH%\mytools\wget\wget.exe" -S --output-document="%LOCALPATH%\geodb\GeoLiteCity.dat.gz" "http://www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz"
"%LOCALPATH%\mytools\wget\wget.exe" -S --output-document="%LOCALPATH%\geodb\GeoIP.dat.gz" "http://www.maxmind.com/download/geoip/database/GeoIP.dat.gz"
rem
rem -d = unzip
rem -f = force
rem -v = verbose
rem
"%LOCALPATH%\mytools\gzip.exe" -dfv "%LOCALPATH%\geodb\GeoLiteCity.dat.gz"
"%LOCALPATH%\mytools\gzip.exe" -dfv "%LOCALPATH%\geodb\GeoIP.dat.gz"

You can verify the databases were updated by viewing the Date modified column when you view the directory in details mode.