免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1895 | 回复: 0
打印 上一主题 下一主题

php5.2 geoip pecl模块安装 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-05-25 18:47 |只看该作者 |倒序浏览

               
Author:
David
|
English Version

【转载时请务必以超链接形式标明文章原始出处和作者信息及
本声明

URL:
http://blog.iyi.cn/start/2007/04/php52_geoip_pecl.html
                                          
首先
下载GeoIP.dat和GeoLiteCity.dat,到www.maxmind.com网站上找最新的下载,放到/usr/local/share/GeoIP/,将GeoLiteCity.dat该名为GeoIPCity.dat
下载geoip c library:
fetch http://www.maxmind.com/download/geoip/api/c/GeoIP-1.4.2.tar.gz
tar -xzvf GeoIP-1.4.2.tar.gz
cd GeoIP-1.4.2
./configure --with-city="yes" --with-dbdir=/usr/local/share/GeoIP/
make
make install

http://pecl.php.net/package/geoip
下载geoip的pecl模块:
wget http://pecl.php.net/get/geoip-0.2.0.tgz
tar -xzvf geoip-0.2.0.tgz
cd geoip-0.2.0
/home/php/bin/phpize
./configure  -enable-geoip -with-php-config=/YOUR_PHP_PATH/bin/php-config
configure出错,configure: error: wrong geoip lib version or lib not
found,修改configure,在404x左右行加上 eval
"$as_ac_Lib=yes"再configure(我自己的办法,可以用,但不保证没有问题)
make
make install
把生成的geoip.so copy到php extension目录,修改php.ini,加上extension = geoip
/YOUR_PATH_TO_APACHE/bin/apachectl restart
不出意外,应该可以了:)
新建一个php文件,写入下面的文本:
$country = geoip_record_by_name('66.249.72.235');
if ($country) {
        echo 'This host is located in: ';
        print_r($country);
}
在浏览器浏览,显示入下信息表示成功了:
This host is located in: Array ( [country_code] => US [region] =>
CA [city] => Mountain View [postal_code] => 94043 [latitude]
=> 37.4192008972 [longitude] => -122.057403564 [dma_code] =>
807 [area_code] => 650 )
用法参考pecl的documentation:
http://www.php.net/manual/en/ref.geoip.php
GeoIP服务提供商: http://www.maxmind.com/app/php


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/62117/showart_1944521.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP