Enabling GeoIP Extension for PHP

Tags: geoIPPECLphp

Published on: July 25, 2014 by Vipin R.N

Enabling GeoIP Extension for PHP


We had a requirement to enable GeoIP for PHP. The scenario is the server is equipped with PHP 5.2.17 and later PHP 5.3.22 was installed on it alongside. Thus users would be able to switch to PHP 5.3.22 by adding a handler in the .htaccess file.


Enable GeoIP extension in PHP 5.3.22

PHP extensionGeo IP
FunctionMap IP address to Geographic locations
DescriptionThis PHP extension allows you to find the location of an IP address – City, State, Country, Longitude, Latitude, and other information as all, such as ISP and connection type.

Pre-Requisite Information

PHP 5.3.22 is installed at the location /usr/local/php53.  I’ve gone ahead installing the GeoIP module using PECL 

PECL – PECL is a repository for PHP Extensions, providing a directory of all known extensions and hosting facilities for downloading and development of PHP extensions. The packaging and distribution system used by PECL is shared with its sister, PEAR.

GeoIP 1.0.8 is the latest stable version available. So lets go for it

root@server [/usr/local/php53/bin]# ./pecl install geoip-1.0.8

The last entries in the process is read as given below

Build process completed successfully
Installing '/usr/local/php53/lib/php/extensions/no-debug-non-zts-20090626/'

 So now lets edit the php.ini at /usr/local/php53/lib file to make


Once this done,  check whether the module is enabled or not

#/usr/local/php53/bin/php -i | grep geoip


geoip support => enabled

geoip extension version => 1.0.8

geoip library version => 1004005

geoip.custom_directory => no value => no value

Done 🙂



Category : cPanel, Linux

Vipin R.N

Vipin R.N

Vipin is a no-nonsense, disciplined guy who ensures that everything is carried out with the highest level of perfection. Apart from his great coding skills, he is quite interested in advanced server administration, issue analysis, documentation and training. In-depth knowledge in international politics, ammunition and automobiles makes this hard core Manchester United fan, one of the most referenced personalities in the entire team.

You may also read:


Add new commentSIGN IN

Let's Connect

Get new updates


$0.000 items