How to setup GeoIP support for apache2 On Debian Etch

This is an apache2 module for finding the country that a web request originated from. It uses the GeoIP library and database to perform the lookup.This module only works on Apache 2.0.x servers.

First you need to make sure you have apache2 server installed and working fine.

Installing mod_geoip in Debian etch using the following command

#aptitude install libapache2-mod-geoip

This will complete the installation

Configuring Geoip

Now you need to open /etc/apache2/mods-available/geoip.conf file and uncomment the GeoIPDBFile line so that the file looks as follows

#vi /etc/apache2/mods-available/geoip.conf

<IfModule mod_geoip.c>
GeoIPEnable On
GeoIPDBFile /usr/share/GeoIP/GeoIP.dat

Now you need to restart Apache using the following command

#/etc/init.d/apache2 restart

Test Geoip

To see if mod_geoip is working correctly, we can create a small PHP file in one of our web spaces (e.g. /var/www):

#vi /var/www/geoiptest.php

add the following lines and save the file

open browser http://serverip/geoiptest.php, and it should display your country.

Sponsored Link

3 thoughts on “How to setup GeoIP support for apache2 On Debian Etch

  1. Hey,
    nice article, but it’s a bit confusing. There are way to get country data of another IPs?

  2. I’ve installed OK on Debian 2.6.18 – no errors, and all the files appear to be in place. I’ve uncommented the /etc/apache2/modules-available/geoip.conf line

    GeoIPDBFile /usr/share/GeoIP/GeoIP.dat

    as mentioned here.

    However running a simple PHP test script produces the output

    Country name : N/A
    Country code : —

    So, although the module is working (the ‘N/A’ comers form it) either it really doesn’t know which country my IP is in (unlikely) or I’ve done something wrong. Anyone got any suggestions?

  3. hi there im working on something like this and i cant get it work properly.

    1. main server is located in london, using geoip to get continet code to show of a visitor connecting to web server. there are several web domains connecting to it as http and www as well

    2. i want to incoming header and address using continent geoip code forward it to another reverse proxy located in another continent using geoip. reverse proxy has already a database of running web addresses and where to looking for files on original web server

    3. i just do not know how to use header coming to main server and forward it to reverse proxy so reverse proxy would see it as coming straight to it. main server should not have a database of running web sites. just a plain redirection using geoip to reverse proxy on another continet

    i know this shouldbe easy i just need help

    thanx, john

Leave a comment

Your email address will not be published. Required fields are marked *