GeoIP install Manual on CentOS/RedHat Enterprise
1)Install the base GeoIP and related libraries:
yum install GeoIP GeoIP-devel GeoIP-data
2)Install the necessary stuff to install the module with APXS:
yum install httpd-devel apr-devel
3)Download the mod_geoip source, and untar it:
wget
http://geolite.maxmind.com/download/geoip/api/mod_geoip2/mod_geoip2_1.2.5.tar.gz
wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.6.tar.gz
tar -xzvf mod_geoip2_1.2.5.tar.gz -C /usr/local/mod_geoip2_1.2.5
tar -xzvf GeoIP-1.4.6.tar.gz -C /usr/local/GeoIP-1.4.6
wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.6.tar.gz
tar -xzvf mod_geoip2_1.2.5.tar.gz -C /usr/local/mod_geoip2_1.2.5
tar -xzvf GeoIP-1.4.6.tar.gz -C /usr/local/GeoIP-1.4.6
4)Run the APXS install:
apxs -i -a -L/usr/local/lib -I/usr/local/include -lGeoIP -c /usr/local/ mod_geoip2_1.2.5/mod_geoip.c
This will generate a mod_geoip.so in /etc/httpd/modules, and add a line to /etc/httpd/conf/httpd.conf:
This will generate a mod_geoip.so in /etc/httpd/modules, and add a line to /etc/httpd/conf/httpd.conf:
LoadModule geoip_module modules/mod_geoip.so
make sure
the line 'LoadModule rewrite_module modules/mod_rewrite.so' line is uncommented.
5)modify /etc/httpd/conf/httpd.conf
#below lines place after the line: 'LoadModule rewrite_module modules/mod_rewrite.so' .
GeoIPEnable On
GeoIPDBFile /usr/local/ GeoIP-1.4.6/data/GeoIP.dat
GeoIPDBFile /usr/local/ GeoIP-1.4.6/data/GeoIP.dat
# below lines Must place in VirtualHost define if you had defined one Virtual Host in CentOS 5 / RedHat Enterprise 5.3.
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CN$
RewriteRule ^(.*)$ http://news.sina.com.cn$1 [L]
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CN$
RewriteRule ^(.*)$ http://news.sina.com.cn$1 [L]
6)restart Apache
本文档详细介绍了如何在CentOS或Red Hat Enterprise系统上安装并配置GeoIP模块。包括安装必要的库文件、下载源码包、编译安装模块、配置Apache及重启服务等步骤。
9536

被折叠的 条评论
为什么被折叠?



