Installing and using maxmind geolocator database and API

Execute from bash:

cd htdocs/
curl -sS | php
emacs composer.json

Edit composer.json so that it contains:

# cat composer.json
    "require": {
        "geoip2/geoip2": "0.6.*"


php composer.phar install

Get the Maxmind free geoip database:

cd /path/to/yourphpfile
wget -O GeoLite2-City.mmdb.gz
gunzip GeoLite2-City.mmdb.gz
ln -s GeoLite2-City.mmdb GeoIP2-City.mmdb

Now you can use the simple example provided at maxmind, or the one I have created: