1. Install dependent Geoip-devel,geoip
Yum Install geoip.x86_64 geoip-devel.x86_64
2. Configure IP Database Geoip.dat,geolitecity.dat
-N http://geolite.maxmind.com/download/geoip/database/geolitecountry/geoip.dat.gz Gunzip GeoIP.dat.gz/usr/local/share/geoip/
wget http:Geolite.maxmind.com/download/geoip/databasegunzip geolitecity.dat.gzmkdir -v /usr/share/geoipmv -v GeoLiteCity.dat /usr/share/geoip/ GeoIPCity.dat
Reference:
- http://dev.maxmind.com/geoip/legacy/install/country/
- http://forum.directadmin.com/showthread.php?t=43309
3. Install the extension
git clonegit@ Github.com:billfeller/configure --with-php-config= /usr/local/php/bin/php-config --with-geoipmake && make install
4. Testing
#/usr/local/php/bin/php-r ' Print geoip_country_code3_by_name ("220.181.112.244"). Php_eol; ' CHN[Root@~/wade/pecllearning/geoip]#/usr/local/php/bin/php-r ' Print_r (geoip_record_by_name ("php.net")); Array([Continent_code] => NA[Country_code] => US[Country_code3] => USA[Country_name] => states[Region] => CA[City] => Fremont[Postal_Code] =>94539 [latitude] => 37.51549911499 [longitude =>-121.8962020874 [dma_code "= > 807 [area_code => 510)
Note that because there is no GeoIPRegion.dat locally, the call to Geoip_region_by_name will be reported warning, as follows
#/usr/local/php/bin/php-r ' Print geoip_region_by_name ("220.181.112.244"); ' PHP Warning:geoip_region_by_name(): Required database not available at /usr/share/geoip/geoipregion.dat. in Command Line code on line 1 warning:geoip_region_by_name ( ): Required database not available at /usr/share/geoip/geoipregion.dat. in Command Line code on line 1
GeoIP PHP Extensions installation and configuration