Install GeoIP on PHP

Hello,

i had to check which country some visitors come from when visiting a website and i remembered that awstats (statistik tool) uses a plugin called GeoIP. But awstats is written in perl and i asked myself if the extension does not exist for php and guess what: it exists! Here is a small howto to install it on CentOS:

I found GeoIP in a third-party repository named EPEL. Check here if you want to now how to install the repository. So now to the installation:

# yum install gcc php-pear geoip geoip-devel
# pecl install geoip

After that you only have to add following line to your php.ini or create geoip.ini in your php.d directory with following content:

extension=geoip.so

Now restart the webserver and you are good to go. Only one note left: geoip is compiled with your actual running php version, so if you upgrade it you have to recompile your geoip installation.

more infors about the geoip functions can be found here.