开发者

gentoo geoip installation [closed]

Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

开发者_高级运维

Closed 10 years ago.

Improve this question

I try to install the geoip extension through SSH on my gentoo server. I did:

emerge Geo-IP

: OK

pecl install geoip

: OK

geoiplookup www.bbc.co.uk

: gives me GeoIP Country Edition: GB, United Kingdom GeoIP City Edition, Rev 1: GB, N7, Tadworth, (null), 51.283298, -0.233300, 0, 0 GeoIP City Edition, Rev 0: GB, N7, Tadworth, (null), 51.283298, -0.233300

Seems fine ! Now I try to add this as php extension: I added

extension=/usr/local/php5/lib/php/extensions/geoip.so

to php.ini

and restatred apache with

/etc/init.d/apache restart

BUT my phpinfo() does not contain any geoip library and

Gives me error: Call to undefined function geoip_record_by_name()

Can someone help me to install geoip on gentoo ?

Thanks


Have you checked if file: /usr/local/php5/lib/php/extensions/geoip.so exists at all? if not, use find command to look for it:

find /usr -name "geoip.so" -print

and put proper path after extension=

If that fails to find it, unless you want to have it installed through pecl, you might want to install gentoo package for this:

emerge -v dev-php5/pecl-geoip


What would we do without google? i found some instructions here: http://www.pc-freak.net/blog/how-to-install-and-setup-and-test-geoip-support-in-php-on-apache2-in-debian-lenny-linux/ and here: http://no2.php.net/manual/en/install.pecl.php

# emerge dev-php/pecl-geoip 
 * Last emerge --sync was 43d 4h 12m 46s ago.
>>> Verifying ebuild manifests
>>> Starting parallel fetch
>>> Emerging (1 of 2) dev-libs/geoip-1.4.8
>>> Installing (1 of 2) dev-libs/geoip-1.4.8
>>> Emerging (2 of 2) dev-php/pecl-geoip-1.0.7-r1
>>> Installing (2 of 2) dev-php/pecl-geoip-1.0.7-r1
>>> Recording dev-php/pecl-geoip in "world" favorites file...
# /etc/init.d/apache2  restart 
 * apache2 not running (no pid file)
 * Starting apache2 ...       [ ok ]

# cd /usr/share/GeoIP
# wget http://www.pc-freak.net/bshscr/geoip_update.sh 
--2012-02-23 15:09:01--  http://www.pc-freak.net/bshscr/geoip_update.sh
Resolving www.pc-freak.net... 83.228.93.76
Connecting to www.pc-freak.net|83.228.93.76|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 270 [application/x-sh]
Saving to: `geoip_update.sh'

100%[=============================>] 270         --.-K/s   in 0s      

2012-02-23 15:09:01 (54.4 MB/s) - `geoip_update.sh' saved [270/270]

# bash geoip_update.sh 
--2012-02-23 15:10:07--  http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
Resolving geolite.maxmind.com... 174.36.207.186
Connecting to geolite.maxmind.com|174.36.207.186|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 17572430 (17M) [text/plain]
Saving to: `GeoLiteCity.dat.gz'

100%[=============================================>] 17,572,430  2.63M/s   in 9.0s    

2012-02-23 15:10:16 (1.86 MB/s) - `GeoLiteCity.dat.gz' saved [17572430/17572430]

# ln -s  GeoLiteCity.dat  GeoIPCity.dat 

# cd /var/www/raptor.lan/htdocs/ # <-- MY WEB ROOT
# mkdir -p tmp/geoip
# cd tmp/geoip/
# cat hmz.php 
<?php

echo "<pre>";
print_r(geoip_record_by_name('php.net'));

?>
# curl http://localhost/tmp/geoip/hmz.php
<pre>Array
(
    [continent_code] => NA
    [country_code] => US
    [country_code3] => USA
    [country_name] => United States
    [region] => CA
    [city] => Sunnyvale
    [postal_code] => 94089
    [latitude] => 37.424900054932
    [longitude] => -122.0074005127
    [dma_code] => 807
    [area_code] => 408
)

mission accomplished?

btw. your config might be wrong.

# equery f dev-php/pecl-geoip  | grep ini 
/etc/php/apache2-php5.3/ext-active/geoip.ini
/etc/php/apache2-php5.3/ext/geoip.ini
/etc/php/cli-php5.3/ext-active/geoip.ini
/etc/php/cli-php5.3/ext/geoip.ini
raptor: ~
# cat /etc/php/apache2-php5.3/ext-active/geoip.ini 
extension=geoip.so
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜