GeoIP + PHP Usage
Method One:
Download GeoIP PHP file Geoip.inc, save as Geoip.inc.php
Http://sjolzy.cn/php/GeoIP/bak/geoip.inc
PHP uses code
Note: If you test locally because $_server[' remote_addr ' and $_server[' REMOTE_ADDR '] may be 127.0.0.1, the output content is empty. Can bring in the IP test yourself
Method Two:
Installing GeoIP into PHP extensions
Yum Install GeoIP Geoip-data geoip-devel
Download GeoIP Database
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
Gzip-d GeoLiteCity.dat.gz
MV Geolitecity.dat/var/lib/geoip/geoipcity.dat
Download GeoIP PECL Extension
Download Address Http://pecl.php.net/package/geoip
Wget-c http://pecl.php.net/get/geoip-1.0.7.tgz
TAR-ZXVF geoip-1.0.7.tgz
Installing the GeoIP PECL extension
CD geoip-1.0.7
/usr/local/php/bin/phpize
./configure--with-php-config=/usr/local/php/bin/php-config--with-geoip
Make
Make install
Add in the php.ini.
Extension=geoip.so
Then restart PHP (nginx+php, and apache+php will not have to restart)
Now, you can use the GeoIP partial function in the PHP manual.
http://cn.php.net/manual/en/book.geoip.php
Reference: http://blog.csdn.net/prince2270/article/details/4592753
The above describes the geoip+php example: Get the country name and code through IP, including the content of the aspects, I hope to be interested in PHP tutorial friends helpful.