Hot wo install geoip and mod-geip2 to Apache in CentOS 5.5 Linux

Saturday, 20th November 2010

Today I had to to install the mod_geoip on CentOS 5.5 final, here are the steps in which I succesfully installed the mod_geoip to Apache.

1. Install the GeoIP and GeoIP-devel GeoIP-data and zlib-devel packages with yum

[root@centos hipo]# yum install GeoIP GeoIP-devel GeoIP-data zlib-devel

2. Use and set my geoip_update.sh script to constantly keep your GeoIP Country and City database up2date

You can download the geoip_update.sh geoip city and countriy database update script here

You will need further to set the script to execute on your root crontab, I’ve placed the following cron rules in my root’s cron;

[root@centos hipo]# echo "02 00 1 * * /usr/sbin/geoip_update.sh >/dev/null 2>&1" | crontab -

Accustom the cron to your time of need.

3. Install the httpd-devel and arp-devel rpms via yum, necessery to be able to compile mod_geip after that

[root@centos hipo]# yum install httpd-devel apr-devel

Download and unarchive the mod_geip2 source code

The latest release of mod_geoIP presently is 1.2.5, however at the time you’re trying that there could be a newer release so check with a browser on http://geolite.maxmind.com/download/geoip/api/mod_geoip2/ to assure which one you’ll need to download.

In my case I issued:

[root@centos hipo]# wget http://geolite.maxmind.com/download/geoip/api/mod_geoip2/mod_geoip2_1.2.5.tar.gz
[root@centos hipo]# tar xvzf mod_geoip2_1.2.5.tar.gz
[root@centos hipo]# cd mod_geoip2_1.2.5

4. Use the apache apxs (Apache Extension Tool) to compile the mod_geoip module

[root@centos hipo]# apxs -i -a -L/usr/lib64 -I/usr/include -lGeoIP -c mod_geoip.c

This command should install the mod_geoip.so module to /usr/lib64/httpd/modules/mod_geoip.so and add a LoadModule directive in your CentOS Apache server.
Anyhow I do recommend you check that your /etc/httpd/conf/httpd.conf contains the following line included:

LoadModule geoip_module /usr/lib64/httpd/modules/mod_geoip.so

5. Put the following Apache configuration again in /etc/httpd/conf/httpd.conf

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

6. In your /etc/php.ini add after the last line of the file

extension=geoip.so

7. Restart the httpd server for the changes to take effect

[root@centos: /root ]# /etc/init.d/httpd restart

Share this on:

Download PDFDownload PDF

Tags:

2 Responses to “Hot wo install geoip and mod-geip2 to Apache in CentOS 5.5 Linux”

  1. Chuman says:
    Google Chrome 13.0.782.112 Google Chrome 13.0.782.112 Windows 7 x64 Edition Windows 7 x64 Edition
    Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1

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

    the following in the httpd.conf file didn’t work, gives error …

    View CommentView Comment
  2. admin says:
    Epiphany 2.30.6 Epiphany 2.30.6 Debian GNU/Linux x64 Debian GNU/Linux x64
    Mozilla/5.0 (X11; U; Linux x86_64; en-us) AppleWebKit/531.2+ (KHTML, like Gecko) Version/5.0 Safari/531.2+ Debian/squeeze (2.30.6-1) Epiphany/2.30.6

    Hi Chuman,

    Please make sure /usr/share/GeoIP/GeoIP.dat and /usr/share/GeoIP/GeoLiteCity.dat
    are existing files?

    Maybe for some reasons the files are not there or smth?

    View CommentView Comment

Leave a Reply

CommentLuv badge