这个模块需要geo数据库和读取数据库的库文件。
#Get the free database of geo_city
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
#Get the free database of geo_coundty
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
#Get the libgeoip. In debian you can do like this:
sudo apt-get install libgeoip-dev
#In other systems, you can download the source and compile it youself.
wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz
CentOS中可以使用yum:
yum install geoip-devel
编译:
./configure --with-http_geoip_module
示例配置:
http {
geoip_country GeoIP.dat;
geoip_city GeoLiteCity.dat;
...