27Feb/103
Installing the GeoIP Apache module
This module allows you to determine which country, region, city, postal code, area code the visitor is coming from.
1. Install the module
apt-get install libapache2-mod-geoip
2. Restart Apache
/etc/init.d/apache2 restart
3. Create a new PHP file to test the module (pico /var/www/test.php or any file you can access on your server)
<?php
print_r($_SERVER);
?>
4. Navigate to the new file in a web browser (http://yourserver/test.php)
The response will be something like this:
Array
(
[GEOIP_COUNTRY_CODE] => GB
[GEOIP_COUNTRY_NAME] => United Kingdom
...
)

February 28th, 2010 - 13:20
Interesting, but is it possible to create a rule to restrict accesss by region or city?
March 1st, 2010 - 20:11
Yes you can but you may require a license for that. Check the GeoIP Apache module web: http://www.maxmind.com/app/ip-location
October 12th, 2010 - 23:51
I’ve installed OK on Debian 2.6.18 and I’ve also uncommented the /etc/apache2/modules-available/geoip.conf line
GeoIPDBFile /usr/share/GeoIP/GeoIP.dat
which information elsewhere suggests is needed.
However running a simple PHP test script produces the output
Country name : N/A
Country code : –
So, either it really doesn’t know which country my IP is in (unlikely) or I’ve done something wrong. Anyone got any suggestions?