in Web

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)


4. Navigate to the new file in a web browser (http://yourserver/test.php)

The response will be something like this:

[GEOIP_COUNTRY_NAME] => United Kingdom

Write a Comment


  1. 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?