MyPage is a personalized page based on your interests.The page is customized to help you to find content that matters you the most.


I'm not curious

How to install GeoIP in ubuntu server ?

0
Started on: 11 April 13
Participants: 1
please help me to install GeoIP in ubuntu server.

my preference is maxmind.com geocity.dat

i downloaded the data of country and cities from http://dev.maxmind.com/geoip/downloadable

please give some examples







please help me to install GeoIP in ubuntu server.

my preference is maxmind.com geocity.dat

i downloaded the data of country and cities from http://dev.maxmind.com/geoip/downloadable

please give some examples

This challenge is listed under Networks & IT Infrastructure and Operating Systems Community

Related Posts:

Initiator

1 Suggestion

  1. 04 May 13
    0

    Please try the simple 4 steps:

    We installed the package using below 4 steps.

    1.First, make a temporary directory to download the GeoLite City database.

    mkdir /tmp/geoip

    Now move into the directory that you just created.

    cd /tmp/geoip

    Now, that you're in the /tmp/geoip directory, go ahead and download the GeoLite City binary database from MaxMind.

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

    You'll notice that the database is gzip compressed, so you'll have to uncompress the database before you can use it.

    gunzip GeoLiteCity.dat.gz

    Now, it's time to copy the uncompressed database to the location where it will be accessed by the mod-geoip Apache module and also by the C API binary.

    First create the GeoIP directory

    sudo mkdir /usr/local/share/GeoIP

    Now, move the GeoLite City binary database to it's new location.

    sudo mv GeoLiteCity.dat /usr/local/share/GeoIP/

    2. Install the GeoIP C Library

    NOw you need to install the GeoIP C library. Nothing's going to work unless you have this library installed.

    Here's all you have to do.

    If you're not already there, go back to the directory you created earlier in the /tmp directory.

    cd /tmp/geoip

    Now download the GeoIP C library.

    wget geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz

    Extract the archived GeoIP C library that you just downloaded.

    gunzip < GeoIP.tar.gz | tar xvf -

    Now move to the new directory that was created when you extracted the archived GeoIP C library.

    cd GeoIP-*

    Now, configure and install the GeoIP C library by issuing the following commands.

    ./configure

    make

    make check

    sudo make install

    3. Install the MaxMind mod-geoip module for Apache2

    Install the Apache module for Ubuntu

    Installing the mod-geoip module on Ubuntu Linux (and probably other Debian variants) is done easily with the following command.

    sudo apt-get install libapache2-mod-geoip2.1.2

    (Keep in mind though, that when a newer version of mod-geoip is released, the proper version number will need to replace the 2.1.2 version in the above example. Also, the install command might work by removing the version number from the package. However, the following is what I used at the time of this writing to install mod-geoip.)

    Enabling mod-geoip

    Nothing's going to work unless mod-geoip is enabled in your apache2 configuration. You'll need the following lines in your apache2.conf file (located on Ubuntu systems at /etc/apache2/apache2.conf)

    # Load the geoip module

    LoadModule geoip_module /usr/lib/apache2/modules/mod_geoip.so

    <IfModule mod_geoip.c>

    # Activate the GeoIP module

    GeoIPEnable On

    # Specifies the location of the City database and specifies that

    # caching should not be performed

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

    # Specifies the location of the Country database and that

    # caching should not be performed

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

    </IfModule>

    Restart Apache so that changes will take effect

    Restart Apache so your changes will take effect by entering the following command.

    sudo /etc/init.d/apache2 restart

    4. Test your MaxMind GeoIP/GeoLite City Installation

    Now that you've installed MaxMind's GeoLite City binary database, the GeoIP C library, and the mod-geoip module for the Apache web server, you should now test your installation with a simple PHP script that will query the GeoLite City datbase against your IP address and (hopefully) print out some information about your location.

    You can use the following PHP script to test your GeoIP installation

    <?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>';

    ?>

    Now when you call the script in a browser, you should see some information that describes your geographic location.

Awards & Accolades for MyTechLogy
Winner of
REDHERRING
Top 100 Asia
Finalist at SiTF Awards 2014 under the category Best Social & Community Product
Finalist at HR Vendor of the Year 2015 Awards under the category Best Learning Management System
Finalist at HR Vendor of the Year 2015 Awards under the category Best Talent Management Software
Hidden Image Url

Back to Top