Free Geolocation API on your own Server with ShinyGeoip

This is my guide on setting up an instance of ShinyGeoip of your own, my favorite Geolocation API & free alternative to FreeGeoIP which went commercial.

Geolocation API Guide

The API is hosted on a DigitalOcean VPS server in the UK at geoip.nekudo.com which you can test out first, or even use in a live production environment.

Setting up Geolocation API step-by-step;

Please note, ShinyGeoip requires PHP version 7.0 or greater and can be hosted with Apache, Nginx, lighttpd or other URL rewrite supporting web server.

Step 1. Pick a subdomain and point A records to your server IP

Step 2. Download & unzip latest ShinyGeoip release to host

Step 3. Download & unzip latest GeoLite2 City to data folder

Step 4. Edit .htaccess file and point server to www folder;

RewriteEngine on
RewriteCond %{REQUEST_URI} !www/
RewriteRule (.*) /www/$1 [L]

Step 5. Redirect API requests to index.php;

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule api/(.*)$ index.php?$1 [QSA,NC,L]

Step 6. Test out API requests; https://geoip.nekudo.com/api/8.8.4.4

Obviously you need to replace the URL with your own.

Updating the GeoLite2 database provided by Maxmind is quick & easy with the following command. It took 3seconds on a West Coast DigitalOcean server.

php cli/app.php mmdb_update

For examples of what you can do with the ShinyGeoip API check below;

What’s your favorite and free self-hosted Geolocation API?
Also questions on ShinyGeoip are most welcome.

Thanks for visiting and having a read. Please share if possible! David.

Twitter Button Facebook Button Google Button LinkedIn Button

Leave a Reply

Your email address will not be published. Required fields are marked *