在网上找了一堆安装geo ip模块的方法,各种方法都很麻烦。现在本尊(无量牛逼最三三尊)来整理一个最简单的安装方法如下。
1.install GEOIP C Libraryhttp://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.6.tar.gz
./configure
make
sudo make install
2.Install GEOIP PHP Extensionsudo pecl install geoip
3.Following message from step2, for example:Build process completed successfully
Installing '/usr/local/lib/php/20060613/geoip.so'
install ok: channel://pecl.php.net/geoip-1.0.7
configuration option "php_ini" is not set to php.ini location
You should add "extension=geoip.so" to php.ini
4.Install GeoIP databasewget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gzip -d GeoIP.dat.gz
sudo cp GeoIP.dat /usr/local/share/GeoIP/
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
sudo cp GeoLiteCity.dat /usr/local/share/GeoIP/GeoLiteCity.dat
sudo mv /usr/local/share/GeoIP/GeoLiteCity.dat /usr/local/share/GeoIP/GeoIPCity.dat
5.test<?php print_r(geoip_record_by_name('125.63.166.38'));