Install geoip on xampp

Geocoding (finding latitude/longitude for street addresses), Geotagging (tagging media with latitude/longitude coordinates), and Geolocation (finding latitude/longitude of computer with IP X-Forwarded-For). There are some options to install on linux environment:

# 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

geoIP-Dat-Files

Install geoip with php5
# sudo apt-get install php5-geoip (ubuntu)

# sudo yum install php5-geoip (centOS)

Or Try # yum install geoip-devel

# sudo pecl install geoip (with PECL)

In Windows environment we have to add extension “php_geoip.dll” with PHP

Download extension from here : https://www.svnlabs.com/blogs/php-5.2.1_geoip-w32.zip

Copy “php_geoip.dll” to xampp “php/ext” .. add a line in php.ini
“extension=php_geoip.dll” and restart xampp

Linux: “extension=geoip.so”

This extension will work on development system using Windows, Apache 2.2.3 and PHP 5.2.10.
We can
check “geoip” with phpinfo() module is loaded.

<?php
$record
= geoip_record_by_name('www.svnlabs.com');
if (
$record) {
print_r($record);
}
?>

Array
(
    [country_code] => US
    [region] => CA
    [city] => Marina...
    [postal_code] =>
    [latitude] => 23.9776792798
    [longitude] => -128.435796741
    [dma_code] => 867
    [area_code] => 400
)

<?php
$result = geoip_record_by_name('78.aaa.yyy.xxx');
var_dump($result);
?>

There is alternative PHP version of the GeoIP API from MaxMind, but this solution is quite slow on servers. MaxMind uses MaxMind database to display geo locations. 

Published by

Sandeep Verma

I’m an Entrepreneur. I’m proud to work as Blogger, LAMP Programmer, Linux Admin, Web Consultant, Cloud Manager, Apps Developer, Searcher. Concentrate > Observe > Imagine > Launch