Answer the question
In order to leave comments, you need to log in
How to make GeoIP work?
Geoip is worth it. Databases are filled with /usr/share/GeoIP
phpinfo shows
/etc/php.d/geoip.ini
geoip extension version 1.0.8
geoip library version 1004005
geoip.custom_directory no value no value Extension=geoip.so
line is written in php.ini
Nginx is built along with the geo module, nginx -V confirms this.
It is written in nginx.conf
# GeoIP
geoip_country /usr/share/GeoIP/GeoIP.dat; # the country IP database
geoip_city /usr/share/GeoIP/GeoLiteCity.dat; # the city IP database
### SET FASTCGI Variables ###
fastcgi_param GEOIP_CITY_COUNTRY_CODE $geoip_city_country_code;
fastcgi_param GEOIP_CITY_COUNTRY_CODE3 $geoip_city_country_code3;
fastcgi_param GEOIP_CITY_COUNTRY_NAME $geoip_city_country_name;
fastcgi_param GEOIP_REGION $geoip_region;
fastcgi_param GEOIP_CITY $geoip_city;
fastcgi_param GEOIP_POSTAL_CODE $geoip_postal_code;
fastcgi_param GEOIP_CITY_CONTINENT_CODE $geoip_city_continent_code;
fastcgi_param GEOIP_LATITUDE $geoip_latitude;
fastcgi_param GEOIP_LONGITUDE $geoip_longitude;
# For GeoIP
fastcgi_param GEOIP_COUNTRY_CODE $geoip_country_code;
fastcgi_param GEOIP_COUNTRY_NAME $geoip_country_name;
fastcgi_param GEOIP_REGION $geoip_region;
fastcgi_param GEOIP_CITY $geoip_city;
fastcgi_param GEOIP_POSTAL_CODE $geoip_postal_code;
fastcgi_param GEOIP_CITY_CONTINENT_CODE $geoip_city_continent_code;
fastcgi_param GEOIP_LATITUDE $geoip_latitude;
fastcgi_param GEOIP_LONGITUDE $geoip_longitude;
php -m | grep geoip
PHP Warning: Module 'geoip' already loaded in Unknown on line 0
geoip
Answer the question
In order to leave comments, you need to log in
Why do you need an extension in php-fpm?
Nginx sets variables and proxies the request to php-fpm
In the php script, check for the presence of the desired values in the $_SERVER array
print_r($_SERVER);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question