Maxmind GeoIP lookup PHP5

Written by Peter Davies on .

Quick setup for installing Maxmind GeoIP databases so that they can be used by the php5-geoip module in PHP.

First install the PHP module for reading the database: apt-get install php5-geoip

Now download the database and store in the default location:

wget -N http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoLiteCity.dat.gz

mkdir /usr/local/share/GeoIP/
mv GeoLiteCity.dat /usr/local/share/GeoIP/

Now restart apache to make the PHP module active:

apache2ctl graceful

You can now setup a CRON job to pick-up the latest database every two weeks (as per their release schedule).