Sunday, November 1, 2009

GeoIP installation for Linux

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


Create GeoIP data directory if it doesn't already exist

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

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/

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

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

tar -xvzf GeoIP-1.4.5.tar.gz
cd GeoIP-1.4.5

make check

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 was installed in, i.e. /usr/local/lib, to /etc/, and execute ldconfig

  1. Install Geo::IP Perl Module

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


tar -xvzf Geo-IP-1.35.tar.gz
cd Geo-IP-1.35

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

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 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"

sudo make install

sudo make install

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

Source : Antezeta


Anonymous said...

I want to quote your post in my blog. It can?
And you et an account on Twitter?

Ninad said...

What is your AIM?

I don't have Twitter account.

View My Stats