mod_geoip for Apache2 On Debian

This guide explains how to set up mod_geoip with Apache2 on a Debian Squeeze system. mod_geoip looks up the IP address of the client end user. This allows you to redirect or block users based on their country. You can also use this for advertising purposes

To install mod_geoip, we simply run:
apt-get install libapache2-mod-geoip

Then we open /etc/apache2/mods-available/geoip.conf and uncomment the GeoIPDBFile line so that the file looks as follows:
nano /etc/apache2/mods-available/geoip.conf

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

Now restart apache to see the configuration changes in action.

A simple test to see if it works, create a php file:
nano /var/www/test.php

Insert the following content and save the file:

$country_name = apache_note("GEOIP_COUNTRY_NAME");
print "Country: " . $country_name;

Now go to and see the result !


Geef een reactie

%d bloggers liken dit: