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

来源:互联网 发布:通过网络传大文件 编辑:程序博客网 时间:2024/05/14 16:55

               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