Install/Setup GeoIP:
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz gunzip GeoLiteCity.dat.gz sudo mkdir -v /usr/share/GeoIP sudo mv -v GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat
For PHP5:
sudo apt-get install php5-geoip
For PHP7:
sudo apt-get install php-geoip
Let’s test GeoIP:
Add following lines in php
print_r (geoip_db_get_all_info()); var_dump(geoip_record_by_name($_SERVER['REMOTE_ADDR'])); var_dump(geoip_record_by_name('www.example.com'));