nginx:[emerg]此处不允许“服务器”指令

nginx:[emerg]此处不允许“服务器”指令

尝试配置服务器时收到以下错误消息:

[]# nginx -s reload
nginx: [emerg] "server" directive is not allowed here in /etc/nginx/conf.d/hello-world.conf:1

配置如下:

/etc/nginx/nginx.conf:

...
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    ...

    index   index.html index.htm;

    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        server_name  localhost;
        root         /usr/share/nginx/html;
        location / {
        }
    }
}

/etc/nginx/conf.d/hello-world.conf:

server {
    listen 80;
    server_name my.server;

    root    i/var/www/hello-world;
    index   index.html;

    location / {
    }
}

nginx 版本:nginx/1.6.2 操作系统:CentOS-70-64-minimal

我猜测它没有获取到server里面的指令,http因为当我将 hello-world.conf 的内容复制到 nginx.conf 之后include它就起作用了。

有人可以帮我吗?

相关内容