Published on: July 25, 2014 by Vipin R.N
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 extension||Geo IP|
|Function||Map IP address to Geographic locations|
|Description||This 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.|
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/geoip.so'
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 geoip support => enabled geoip extension version => 1.0.8 geoip library version => 1004005 geoip.custom_directory => no value => no value
Category : cPanel, Linux