profruit ~ $ file /usr/share/GeoIP/GeoIP.dat
/usr/share/GeoIP/GeoIP.dat: dataПредназначението на този файл е да локализира peer-и в приложения като bittorrent. Определено този файл е безполезен за нуждите на PHP.
ИНСТАЛАЦИЯ
Инсталацията е прозрачна сведена до няколко минути време. Първите три команди са наследство от тема: Failed loading opcache.so в PHP 5.4 под Ubuntu 12.04## sudo apt-get install php5-dev ## sudo apt-get install build-essential ## sudo apt-get install php-pearphp5-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
build-essential is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
php-pear is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Следва инсталация на:
sudo apt-get install php5-geoipphp5-geoip
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 11.2 kB of archives.
After this operation, 73.7 kB of additional disk space will be used.
sudo apt-get install libgeoip-devgeoip-bin libgeoip-dev
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 244 kB of archives.
After this operation, 831 kB of additional disk space will be used.
добавяме още:
sudo pecl install geoipdownloading geoip-1.0.8.tgz ...
Starting to download geoip-1.0.8.tgz (10,061 bytes)
.....done: 10,061 bytes
...
...
...
Build process completed successfully
Installing '/usr/lib/php5/20100525+lfs/geoip.so'
install ok: channel://pecl.php.net/geoip-1.0.8
configuration option "php_ini" is not set to php.ini location
You should add "extension=geoip.so" to php.in
Теглим архива.
wget -N http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gzРазтваряме го.
gunzip GeoLiteCity.dat.gzМестим го в /usr/share/GeoIP/ под ново име.
sudo mv -v GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat
Информативно за новия файл.
profruit ~ $ ls -la /usr/share/GeoIP/GeoIPCity.dat
-rw-rw-r-- 1 profruit profruit 18578007 /usr/share/GeoIP/GeoIPCity.datТака че едно на ум, кой ще чете, кой ще пише ...
РЕДАКЦИЯ НА PHP.INI
Създаваме нова секция с следното съдържание:[geoip] ;A GeoIP database to accurately determine the IP address. ;A PECL extension compared to MaxMind's PHP API. geoip.custom_directory = /usr/share/GeoIP/ extension = geoip.so
ТЕСТ
В променливата $domain задаваме името на интересуващия ни сайт.<?php
$domain = 'profruit.blogspot.com';
if ( function_exists( 'geoip_record_by_name' ) ) {
echo "резултати за: $domain" , '<br>';
echo '<pre>' . print_r( geoip_record_by_name( $domain ), true ) . '</pre>';
}
else echo 'function not exists!';
?>
И получаваме нещо такова.
резултати за: profruit.blogspot.com
Array
(
[continent_code] => NA
[country_code] => US
[country_code3] => USA
[country_name] => United States
[region] => CA
[city] => Mountain View
[postal_code] => 94043
[latitude] => 37.419200897217
[longitude] => -122.05740356445
[dma_code] => 807
[area_code] => 650
)
връзки:
Geo IP Location - php.net
How To Configure GeoIP (PECL) On An Ubuntu 12.04

до нови срещи ^.^

0 Response to "Инсталация на GeoIP в Ubuntu 12.04"
Публикуване на коментар