RSS
people

Setup IP to city/country detection using geoIP in php

Following instructions are for apache on ubuntu.

# Install GeoIP module for php5
sudo apt-get install php5-geoip
 
# Restart Apache
sudo /etc/init.d/apache2 restart
 
# Now, the country wide data is automatically installed with geoIP module. 
# But, if we want to have it at city level - we need to download the data.
# Here we are downloading the free database. Steps for paid database will be same
wget -N http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
 
# Now, extract the file
gunzip GeoLiteCity.dat.gz
 
# Time to copy the file to proper location
sudo cp GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat

Please note that we changed the name of the file. In case of paid version, changing the name won’t be required.

{EAV:a82470a74d7b9ec4}

No Comments | Tags: , , , , , ,