Installing mod_geoip On Ubuntu


sudo su


Installing mod_geoip

To install mod_geoip, we simply run:

apt-get install libapache2-mod-geoip

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

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

Next we restart Apache:

/etc/init.d/apache2 restart

That’s it already!


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

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

Call that file in a browser, and it should display your country (make sure that you’re calling the file from a public IP address, not a local one).


Leave a comment

Leave your opinion

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

  • Recent Posts

  • Advertisements
%d bloggers like this: