Creating customised content based on the origin country of your website visitors requires installing the mod_geoip module for Apache and also the MaxMind GeoIP database as follows (on CentOS):
mkdir ~/geoip
cd ~/geoip
wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz
tar xzf GeoIP*
cd GeoIP*
./configure
make
make check
make install
cd ..
wget http://geolite.maxmind.com/download/geoip/api/mod_geoip2/mod_geoip2_1.2.5.tar.gz
tar xzf mod_geoip2_1.2.5.tar.gz
cd mod_geoip2_1.2.5
The next command requires that you already have the httpd-devel package installed. If you do not have the /usr/sbin/apxs file then install with:
yum install httpd-devel
/usr/sbin/apxs -i -a -L/usr/local/lib -I/usr/local/include -lGeoIP -c mod_geoip.c
cd /usr/share/
mkdir GeoIP
cd GeoIP/
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gunzip GeoIP.dat.gz
Add the following to any virtual hosts that want to use GeoIP:
<IfModule mod_geoip.c>
GeoIPEnable On
GeoIPDBFile /usr/share/GeoIP/GeoIP.dat
</IfModule>
Create test file to check that it works and then visit it. You should see the GeoIP stuff in the output:
<?php
echo $_SERVER[‘GEOIP_COUNTRY_CODE’];
echo “<hr>”;
print_r($_SERVER);
?>