1.下载geoip的php扩展库 wget http://pecl.php.net/get/geoip-1.1.1.tgz
tar zxvf geoip-1.1.1.tgz
cd geoip-1.1.1
phpize
./configure --with-php-config=/usr/bin/php-config --with-geoip
make &make install
2.配置php支持geoip扩展
[root]# ll /usr/lib64/php/modules/
cd /etc/php.d/ && echo "extension=geoip.so" >> geoip.ini && echo "geoip.custom_directory=/var/lib/GeoIP/ " >> geoip.ini
3.重启apache:
[root]# service httpd restart
4.测试函数库能否使用:
[root@10-11-50-18 php.d]# php -r 'print_r(geoip_record_by_name("36.44.108.122"));'
Array
(
[continent_code] => AS
[country_code] => CN
[country_code3] => CHN
[country_name] => China
[region] => 26