在CentOS 5/RedHat Enterprise 5.3上编译安装GeoIP

本文档详细介绍了如何在CentOS或Red Hat Enterprise系统上安装并配置GeoIP模块。包括安装必要的库文件、下载源码包、编译安装模块、配置Apache及重启服务等步骤。

               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
  
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:
 
                           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
 
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]
 
6)restart Apache  
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值