---
title: "Maxmind GeoIP lookup PHP5"
date: "2013-09-24"
path: "/161-maxmind-geoip-lookup-php5.html"
section: "/ramblings"
aliases:
  - "/161"
  - "/161-maxmind-geoip-lookup-php5"
  - "/161.html"
  - "/ramblings/161-maxmind-geoip-lookup-php5.html"
---

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).
