Archive | September, 2013

Install Perl Geo::IP cpan module on Centos 5 or 6

Installing this Perl module from cpan can be a bit tricky, as it looks for the GeoIP libraries in the wrong place.

You may see messages like this in the output when running : cpan Geo::IP

  • The GeoIP CAPI is not installed you should do that
  • GeoIP must be installed prior to building Geo::IP and I can’t find it in the standard library directories

It’s also compounded by the fact that currently Centos is shipping with a version of GeoIP-devel prior to 1.5, so you can’t install the GeoIP libraries via yum. I tried installing it from yum, and then got this error:

  • Your installed version of libgeoip is outdated!

Here’s the quick solution:

First, compile the GeoIP libraries from the C Source using the default configuration. This is all available from:

http://dev.maxmind.com/geoip/legacy/downloadable/

wget http://www.maxmind.com/download/geoip/api/c/GeoIP-latest.tar.gz;
tar xzf GeoIP-latest.tar.gz
cd GeoIP-1.5.1
./configure
make
make check
make install

Now we (hopefully) have the geoip libraries installed, and the latest database installed in /usr/local/share/GeoIP/GeoIP.dat

So, back to cpan. First, enter the cpan> shell (just run the cpan command on it’s own). Then enter the following command to fetch and locate the package installation files:

look Geo::IP

This will locate and download the source package for the module, and put you in the installation directory e.g.

/steve/.cpan/build/Geo-IP-1.42-V2q_q_

So, now we need to tell the package installer where to find the GeoIP libraries we previously installed from source and install the module manually.

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