Sunday, February 1, 2015

GEOIP pear pecl PHP extension for location IP based conversion to city country, longitude, latitude

  1. Download .dat.gz databases from maxmind: http://geolite.maxmind.com/download/geoip/database/
  2. Install geoip via yum.
    yum install GeoIP GeoIP-devel
  3. You also might want to download database with ip addresses from Maxmind website and place it in /usr/share/GeoIP (which is a default location of geoip upon installation).
  4. Install PECL extension
    pecl install geoip
  5. Add extension=geoip.so to your /etc/php.ini
  6. Restart apache /etc/init.d/httpd restart

For Ubuntu:

apt-get install libgeoip-dev libgeoip1
apt-get install php5-geoip

then you need to copy GeoLiteCity.dat.gz to /usr/share/GeoIP/ and extract it and rename it to GeoIPCity.dat
then restart your web server:

service apache2 restart

No comments:

Post a Comment