Jan
11
Posted on 11-01-2010
Filed Under (Apache, Redhat & Fedora) by Ravi Bhure

How to install GeoIP and mod_geoip2 on centos for apache

1) yum install GeoIP GeoIP-devel GeoIP-data zlib-devel

2) mkdir /usr/local/share/GeoIP

3) Download the latest Country and City database files from maxmind

cd /usr/local/share/GeoIP
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoIP.dat.gz
gunzip GeoLiteCity.dat.gz

4) yum install httpd-devel apr-devel

5) wget http://geolite.maxmind.com/download/geoip/api/mod_geoip2/mod_geoip2_1.2.5.tar.gz

6) tar xvzf mod_geoip2_1.2.5.tar.gz && cd mod_geoip2_1.2.5

7) apxs -i -a -L/usr/lib64 -I/usr/include -lGeoIP -c mod_geoip.c

8) Enabling mod-geoip
Nothing’s going to work unless mod-geoip is enabled in your apache configuration. You’ll need the following lines in your httpd.conf file (located on CentOS systems at /etc/httpd/conf/httpd.conf)

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

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

#/etc/init.d/httpd restart

10) /usr/local/bin/geoipupdate

Similar Posts:

Be Sociable, Share!
(9) Comments    Read More   

Comments

Arun on 14 January, 2010 at 8:29 am #

Good one Ravi
Thx


TuanNguyen on 5 February, 2010 at 1:18 pm #

Thank you. You’re the one.. 🙂


[…] rpm for http with mpm worker (on x86_64) How to install GeoIP and mod_geoip2 on centos for apache How to install GeoIP and mod_geoip2 on centos for apache Taking backup on Tape Как установить & настроить VNC Server на CentOS […]


Amer on 24 May, 2011 at 1:42 am #

Firstly thanks for the tutorial but i get some problem need some help this what I get

so i used this tutorial and got to step 5 and when i do step 6 i get
HTTP request sent, awaiting response… 200 OK
Length: 2691 (2.6K) [text/html]
Saving to: `index.html’
100%[======================================>] 2,691 –.-K/s in 0s
2011-05-23 14:02:45 (53.5 MB/s) – `index.html’ saved [2691/2691]
[root@Proxy GeoIP]# tar xvzf mod_geoip2_1.2.5.tar.gz && cd mod_geoip2_1.2.5
tar: mod_geoip2_1.2.5.tar.gz: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error exit delayed from previous errors
[root@Proxy GeoIP]# ls
GeoIP.dat GeoLiteCity.dat index.html
[root@Proxy GeoIP]# tar xvzf mod_geoip2_1.2.5.tar.gz && cd mod_geoip2_1.2.5
tar: mod_geoip2_1.2.5.tar.gz: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error exit delayed from previous errors


Ravi Bhure on 25 May, 2011 at 3:43 pm #

Hmmmm, My mistake, Thanks Amer, I mistaken left the package name “mod_geoip2_1.2.5.tar.gz ” with download command
to download use following one
wget http://geolite.maxmind.com/download/geoip/api/mod_geoip2/mod_geoip2_1.2.5.tar.gz

Ravi


Tom on 17 January, 2012 at 1:56 am #

Hi,

First thanks for the guide. However, I am getting this output from step 7. Any ideas?

/usr/lib/apr-1/build/libtool –silent –mode=compile gcc -prefer-pic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector –param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -fno-strict-aliasing -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -pthread -I/usr/include/httpd -I/usr/include/apr-1 -I/usr/include/apr-1 -I/usr/include -c -o mod_geoip.lo mod_geoip.c && touch mod_geoip.slo
mod_geoip.c: In function ‘geoip_header_parser’:
mod_geoip.c:328: warning: implicit declaration of function ‘ap_add_common_vars’
mod_geoip.c:423: error: ‘GEOIP_NETSPEED_EDITION_REV1’ undeclared (first use in this function)
mod_geoip.c:423: error: (Each undeclared identifier is reported only once
mod_geoip.c:423: error: for each function it appears in.)
mod_geoip.c:458: warning: implicit declaration of function ‘GeoIP_country_id_by_addr_v6’
mod_geoip.c:546: error: ‘GEOIP_CITY_EDITION_REV0_V6’ undeclared (first use in this function)
mod_geoip.c:547: error: ‘GEOIP_CITY_EDITION_REV1_V6’ undeclared (first use in this function)
mod_geoip.c:303: warning: unused variable ‘gip’
apxs:Error: Command failed with rc=65536
.


Arun Bagul on 6 February, 2012 at 3:51 pm #

Please install Geoip and devel package as shown below (use latest version)
GeoIP-devel-1.4.7-1
GeoIP-1.4.7-1

Thanks,
Arun


Kai on 21 May, 2012 at 4:21 am #

Great tutorial but I install mod_geoip from epel,cuz this is more comfortable for me.

Greetings from germany!


Will on 6 September, 2013 at 3:14 am #

You the man ravi!!


Post a Comment
Name:
Email:
Website:
Comments:


www.flickr.com
arunbagul's photos More of arunbagul's photos
Get Adobe Flash player
-->