1、报错信息
nginx -t校验配置信息如下:
[root@www momo]# nginx -tnginx: [emerg] "server" directive is not allowed here in usr/local/nginx/conf/nginx.conf:53nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
2、问题排查
nginx: [emerg] “server” directive is not allowed here in usr/local/nginx/conf/nginx.conf:53nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed根据报错提示表示在53行的service部分不被允许,那就重新进入配置文件;找到53行的service部分,查看是否配置有问题
#3d地图server {listen 9889;#炼化新版地图;location / {root /map3D/s3mb;index Config.scp;add_header 'Access-Control-Allow-Origin' '*' always;add_header 'Access-Control-Allow-Credentials' 'true';add_header 'Access-Control-Allow-Methods' '*';}#罐区2D地图location /lhgq {root /map3D;index meta.json;add_header 'Access-Control-Allow-Origin' '*' always;add_header 'Access-Control-Allow-Credentials' 'true';add_header 'Access-Control-Allow-Methods' '*';}}
3、问题解决
最终发现少了一个} ,相当于把53行的service部分括出了http模块范围外,所以才会提示这部分service服务不被允许。
把51行加上一个}问题就就解决了。
[root@node-2-215 sbin]# ./nginx -tnginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
文章转载自巴韭特锁螺丝,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




