Oops, an error occurred! Code: 2024042315333563fb6a60

Finding the geographical location of an ip address couldn't be simpler. In a few minutes, you'll have the foundation of a geotargeting/geotracking setup on your Debian based server. 

Here's how to install maxmind geolite city on debian lenny 64 bit.

 

With root privileges, follow the following steps.

Install the mod-geoip module for apache2

 

apt-get update

apt-get install libapache2-mod-geoip

 

DOWNLOAD AND INSTALL THE GeoLite City DATABASE

Download and install the free GeoLite City Database

 

cd /tmp

 

wget geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz

gunzip GeoLiteCity.dat.gz

 

mv GeoLiteCity.dat /usr/share/GeoIP/

Make a simple change to your apache configuration

 

Next, find the file /etc/apache2/mods-available/geoip.conf

 

And edit it so that it's contents look like this:

 

<IfModule mod_geoip.c>

  GeoIPEnable On

  GeoIPDBFile /usr/share/GeoIP/GeoIP.dat Standard

  GeoIPDBFile /usr/share/GeoIP/GeoLiteCity.dat Standard

</IfModule>

Save and close the file after making your edits.

Restart your web server

 

Restart apache with this command:

 

/etc/init.d/apache2 restart

Test out your Maxmind mod-geoip & GeoLite City Installation

 

Now test to see if it works. Create and run a PHP file:

 

vi maxmindtest.php

It's contents should be as follows:

 <?php 
/*

Uses mod-geoip to query the
MaxMind GeoLite City
binary database and returns
geographic information based
on the client's IP address

*/

$country_code = apache_note("GEOIP_COUNTRY_CODE");
$country_name = apache_note("GEOIP_COUNTRY_NAME");
$city_name = apache_note("GEOIP_CITY");
$region = apache_note("GEOIP_REGION");
$metro_code = apache_note("GEOIP_DMA_CODE");
$area_code = apache_note("GEOIP_AREA_CODE");
$latitude = apache_note("GEOIP_LATITUDE");
$longitude = apache_note("GEOIP_LONGITUDE");
$postal_code = apache_note("GEOIP_POSTAL_CODE");

echo 'Country code: '.$country_code.'<br>';
echo 'Country name: '.$country_name.'<br>';
echo 'City name: '.$city_name.'<br>';
echo 'Region: '.$region.'<br>';
echo 'Metro code: '.$metro_code.'<br>';
echo 'Area code: '.$area_code.'<br>';
echo 'Latitude: '.$latitude.'<br>';
echo 'Longitude: '.$longitude.'<br>';
echo 'Postal code: '.$postal_code.'<br>';

?>

After running the above script, you should see information describing your location. If you don't, well, look over the instructions again and see if you skipped a step.