How to install GeoIP and mod_geoip2 on centos for apache
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
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:
- How to install GeoIP and mod_geoip2 on centos for apache
- How to build RPM of PHP for apache with mpm-worker
- How to build rpm for http with mpm worker (on x86_64)
- How to configure-add java extension for php on CentOS 5
- How to install wordpress on Ubuntu Gusty 7.10
- Apache – (28)No space left on device: Cannot create SSLMutex
- How to install Tomcat on Linux
9 Replies to “How to install GeoIP and mod_geoip2 on centos for apache”
Good one Ravi
Thx
Thank you. You’re the one.. 🙂
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
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
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
.
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
Great tutorial but I install mod_geoip from epel,cuz this is more comfortable for me.
Greetings from germany!
You the man ravi!!