GeoIP Information for AWStats

AWStats Logo

Improve country and city location information in your web analytics reports

Web Analytics Services

Tool Selection, Implementation and Training

Bookmark this resource

AWStats offers three different ways to provide Country level information about visitors ("hosts") connecting to your site. By default, the host domain extension is used if you have performed reverse DNS look-up. While this results in human readable host names as well, reverse DNS lookup is time consuming. Alternatively, GeoIP plugins can be used. They match the host IP with a database of IP allocations which is already installed locally on your computer, significantly reducing the time needed to match a host to a location. There are two country level GeoIP databases available. A Geo::IPFree Perl module is available, but it does not appear that the database is being maintained. The better solution is MaxMind's Geo::IP GeoLite Country open source version, said to be 97% accurate. An even more accurate commercial version is also available.

Recently, MaxMind made a free version of its GeoLite City database available. The free version is about 60% accurate; the commercial version improves that to about 75%.

MaxMind's Autonomous System Numbers database works well for organization identification, although the display of AS numbers in AWStats may be incentive enough to license the commercial organization database.

The GeoIP installation can be a bit tedious. The instructions below, for Linux and for MS Windows, should help you get up and running. We conclude with some general observations.

Last updated: 2007-10-10.

[Contents ↓]

GeoIP installation for Linux

Download the current GeoLite Country, GeoLite City and Organization (AS Numbers) databases

wget http://www.maxmind.com/download/geoip/database/GeoIP.dat.gz
wget http://www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
wget http://www.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz

Create GeoIP data directory if it doesn't already exist

if [ ! -d /usr/local/share/GeoIP ] ; then
     mkdir /usr/local/share/GeoIP
fi

Move data files to directory and unzip.

mv GeoIP.dat.gz /usr/local/share/GeoIP/
gunzip /usr/local/share/GeoIP/GeoIP.dat.gz

mv GeoLiteCity.dat.gz /usr/local/share/GeoIP/
gunzip /usr/local/share/GeoIP/GeoLiteCity.dat.gz

mv GeoIPASNum.dat.gz /usr/local/share/GeoIP/
gunzip /usr/local/share/GeoIP/GeoIPASNum.dat.gz

Install the GeoIP program.

There are two options:

  1. Install a C program and a Perl program
  2. Install just a Perl program.

Option a) will provide the fastest performance.

The instructions for a) are known to work using Fedora Core 6 - FC6.

  1. Install GeoIP C API http://www.maxmind.com/app/c

Download the GeoIP-*.tar.gz file, uncompress it and compile.

wget http://www.maxmind.com/download/geoip/api/c/GeoIP-1.4.3.tar.gz tar -xvzf GeoIP-1.4.3.tar.gz -C /usr/local/src/ cd /usr/local/src/GeoIP-1.4.3 ./configure make make check make install

2007-10-10: Thanks to James Rice who notified us of version 1.4.3. 2007-02-21: Thanks to Daniel Wallace who notified us of version 1.4.2. 2007-01-13: Thanks to Daniel Wallace who notified us of version 1.4.1. 2006-09-25: Thanks to Oleg Nerus who notified us of version 1.4.0. 2006-05-21: Thanks to Florian Burka who notified us of the availability of version 1.3.17.

With a text editor, add the directory libGeoIP.so was installed in, i.e. /usr/local/lib, to /etc/ld.so.conf, and execute ldconfig

  1. Install Geo::IP Perl Module

Download the Geo-IP-*.tar.gz file, uncompress it and compile.

wget http://www.maxmind.com/download/geoip/api/perl/Geo-IP-1.27.tar.gz 

tar -xvzf Geo-IP-1.27.tar.gz  -C /usr/local/src/
cd /usr/local/src/Geo-IP-1.27

perl Makefile.PL LIBS='-L/usr/local/lib'
make
make test
make install

Option b) (in lieu of option a!)

PurePerl Module (is slower, but does not require C library). Download latest Geo-IP-PurePerl-*.tar.gz file, uncompress and compile. Replace the version below with the current version.

wget http://www.maxmind.com/download/geoip/api/pureperl/Geo-IP-PurePerl-1.17.tar.gz
tar -xvzf Geo-IP-PurePerl-1.17.tar.gz -C /usr/local/src/
cd /usr/local/src/Geo-IP-PurePerl-1.17
perl Makefile.PL
make
make test
make install

Update your awstats.mysite.conf configuration file

Look for the following geoip LoadPlugin options in your AWStats configuration file. Update them with the full path to each of the two database files.

LoadPlugin="geoip GEOIP_STANDARD /usr/local/share/GeoIP/GeoIP.dat"
LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /usr/local/share/GeoIP/GeoLiteCity.dat"
LoadPlugin="geoip_org_maxmind GEOIP_STANDARD /usr/local/share/GeoIP/GeoIPASNum.dat"

[Contents ↓]

MS Windows

Install Geo::IP Perl Module

open a windows terminal window

For ActivePerl 6xx builds, use:

C:\> ppm install http://theoryx5.uwinnipeg.ca/ppmpackages/Geo-IP.ppd

For 8xx builds, use:

C:\> ppm install http://theoryx5.uwinnipeg.ca/ppms/Geo-IP.ppd

ppm is an ActiveState Perl Module Management system. Follow the prompts to install the Perl modules. Optionally install the GeoIP database. Your output should look like this:

C:\>ppm install http://theoryx5.uwinnipeg.ca/ppms/Geo-IP.ppd
====================
Install 'Geo-IP' version 1.27 in ActivePerl 5.8.7.815.
====================
Installing C:\Perl\site\lib\auto\Geo\IP\IP.dll
Installing C:\Perl\site\lib\auto\Geo\IP\IP.lib
Installing C:\Perl\site\lib\auto\Geo\IP\IP.exp
Installing C:\Perl\site\lib\auto\Geo\IP\IP.bs
Installing C:\Perl\html\site\lib\Geo\IP.html
Installing C:\Perl\html\site\lib\Geo\Mirror.html
Installing C:\Perl\html\site\lib\Geo\IP\Record.html
Files found in blib\arch: installing files in blib\lib into architecture depende
nt library tree
Installing C:\Perl\site\lib\Geo\Mirror.pm
Installing C:\Perl\site\lib\Geo\IP.pm
Installing C:\Perl\site\lib\Geo\IP\Record.pod
Installing C:\Perl\site\lib\Geo\IP\Record.pm

The database GeoIP.dat is needed to complete the installation,
and should be placed in the C:\Program Files/GeoIP directory. I will
now fetch and install this for you, if you like.

Fetch GeoIP.dat? [yes] yes
Fetching http://theoryx5.uwinnipeg.ca/ppms/scripts/GeoIP.dat ...  done!
C:/Program Files/GeoIP does not exist. Create it? [no] yes
GeoIP.dat has been successfully installed to C:/Program Files/GeoIP
Successfully installed Geo-IP version 1.27 in ActivePerl 5.8.7.815.

Update the GeoIP GeoLite Country database. Add the GeoIP GeoLite City and Organization (AS Numbers) databases.

  1. Download the current Country, City and Organization (AS Numbers) databases

http://www.maxmind.com/download/geoip/database/GeoIP.dat.gz
http://www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
http://www.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz

  1. Unzip the files and place them in your GeoIP data directory, i.e. C:\Program Files\GeoIP

Update your awstats.mysite.conf configuration file

Look for the following geoip LoadPlugin options in your AWStats configuration file. Update them with the full path to each of the two database files.

LoadPlugin="geoip GEOIP_STANDARD C:\Program Files\GeoIP\GeoIP.dat"
LoadPlugin="geoip_city_maxmind GEOIP_STANDARD C:\Program Files\GeoIP\GeoLiteCity.dat"
LoadPlugin="geoip_org_maxmind GEOIP_STANDARD C:\Program Files\GeoIP\GeoIPASNum.dat"

NoteVarious people have reported problems using the geoip_org_maxmind plugin with the PurePerl GeoIP module and MS Windows. This appears to have been addressed in the AWStats 6.6 release. Alternatively, you could compile the GeoIP C library (dll). See the note below on this topic. (Added 2006-05-12)

Windows Notes

NotePerformance could be improved by using a solution based on the C code and the associated Perl module, as documented for Linux above. There are Windows gnu C compilers available from mingw.org and cygwin; let us know if you successfully create the GeoIP DLL.

[Contents ↓]

General Observations

The following tips are valid for all environments.

Improve the quality this document by sending your feedback.

[Contents ↓]

Call for translations

If you find this document useful and want to provide a translation in your native language, write us.

Additional AWStats Resources

We have other AWStats resources in this site, including ExtraSections and Robots updates. See our AWStats resource overview for a full listing.


Contents


Let Antezeta help you in the selection, implementation and usage of a Web Analytics solution!

Contact us today to find out more about this topic and the rest of the Web Ecosystem.

Home · Contact Us · Site Map & Search · Keyboard shortcuts · Top ↑