- 安装GEOIP[root@i -it ~]# yum install GeoIP GeoIP-deve
- ##下载GeoIP的数据库,有精确到国家和地区包括IPv6 自行选择...###
- [root@i -it ~]# wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
- ##解压下载的库.###
- [root@i -it ~]# gzip -d GeoLiteCity.dat.gz
- ##移动到目录.###
- [root@i -it ~]# mv GeoLiteCity.dat /www/server/geoip/GeoIPCity.dat
-
- ##下载GeoIP PECL扩展##
- [root@i -it ~]# wget -c http://pecl.php.net/get/geoip-1.1.1.tgz
- [root@i -it ~]# tar -zxvf geoip-1.1.1.tgz
- [root@i -it ~]# cd /www/server/geoip
- [root@i -it ~]# /www/server/php/55/bin/phpize
- [root@i -it ~]# ./configure --with-php-config=/www/server/php/55/bin/php-config --with-geoip
-
- ##操作到此##
-
- [root@i -it ~]# make
- ##make: *** No targets specified and no makefile found. Stop.##
- ## 这里make提示错误。进行到此处。看如何解决##
- [root@i -it ~]# make install
-
- 在 php.ini 里加上
- extension=geoip.so
- 接着重启一下 php 就行了
- 现在,你可以使用 php 手册里的 GeoIP 部份函数了
- http://cn.php.net/manual/en/book.geoip.php
复制代码
上面是我的操作步骤 |