Debian Tutorials Copy/Paste tutorials for Debian Linux

27Feb/102

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
...
)

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • Technorati
  • email
  • Live
  • Slashdot
  • LinkedIn
  • Print
  • Tumblr
  • Twitter
  • Netvibes
  • Netvouz
  • PDF
  • Yahoo! Bookmarks
Comments (2) Trackbacks (0)
  1. Interesting, but is it possible to create a rule to restrict accesss by region or city?

  2. Yes you can but you may require a license for that. Check the GeoIP Apache module web: http://www.maxmind.com/app/ip-location


Leave a comment


No trackbacks yet.