Php 如何在nginx中设置geoIp的路径

Php 如何在nginx中设置geoIp的路径,php,nginx,geolocation,geoip,maxmind,Php,Nginx,Geolocation,Geoip,Maxmind,我正在尝试在centos6上安装Nginx GeoIP模块。 我正在使用此指南安装它: 但是当我试图在nginx.cof中设置GeoIp的路径时,我遇到了这个问题: nginx:[emerg]中的未知指令“geoip_国家” /etc/nginx/nginx.conf:7 nginx:配置文件 /etc/nginx/nginx.conf测试失败 这些是我添加到nginx.conf的行: geoip_country /usr/local/share/GeoIP/GeoIP.dat; geoip_

我正在尝试在centos6上安装Nginx GeoIP模块。
我正在使用此指南安装它:
但是当我试图在
nginx.cof
中设置GeoIp的路径时,我遇到了这个问题:

nginx:[emerg]中的未知指令“geoip_国家” /etc/nginx/nginx.conf:7 nginx:
配置文件 /etc/nginx/nginx.conf测试失败

这些是我添加到
nginx.conf
的行:

geoip_country /usr/local/share/GeoIP/GeoIP.dat;
geoip_city /usr/local/share/GeoIP/GeoLiteCity.dat;
我在谷歌上搜索了这个问题,一个答案是它应该在
main{}
但是当我在nginx.conf中插入
main{}
并在其中插入行时,我看到另一个错误,即
main{}
是错误的!另外,我在其他地方读到,
main{}
是同一个nginx.conf文件
我很困惑,有人能帮我吗?
[更新]
这是我的nginx.conf中的http部分:

http {
    include       /etc/nginx/mime.types;

    # For user configurations not maintained by DirectAdmin. Empty by default.
    include /etc/nginx/nginx-includes.conf;

    # Supplemental configuration
    include /etc/nginx/nginx-modsecurity-enable.conf;
    include /etc/nginx/nginx-defaults.conf;
    include /etc/nginx/nginx-gzip.conf;
    include /etc/nginx/directadmin-ips.conf;
    include /etc/nginx/directadmin-settings.conf;
    include /etc/nginx/nginx-vhosts.conf;
    include /etc/nginx/directadmin-vhosts.conf;

    geoip_country /usr/local/share/GeoIP/GeoIP.dat;
    geoip_city /usr/local/share/GeoIP/GeoLiteCity.dat;

# Set php-fpm geoip variables
fastcgi_param GEOIP_COUNTRY_CODE $geoip_country_code;
fastcgi_param GEOIP_COUNTRY_CODE3 $geoip_country_code3;
fastcgi_param GEOIP_COUNTRY_NAME $geoip_country_name;
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;
}

它有什么问题吗?

需要将
geoip\uu
指令放在
http{…}
块中,该块位于
nginx.conf
文件中。例如:

http {
    geoip_country /usr/local/share/GeoIP/GeoIP.dat;
    geoip_city /usr/local/share/GeoIP/GeoLiteCity.dat;

    server {
        ...
    }
}

有关更多信息,请参阅。

我也将其放在了http部分中,但仍然会出现相同的错误。如果未在配置文件中的其他位置添加模块,则可能需要加载模块。