centos nginx报"server" directive is not allowed here in /etc/nginx/conf.d/default.conf错解决

问题出现的原因是直接使用了default.conf文件

[root@test nginx]# nginx -t -c /etc/nginx/conf.d/default.conf
nginx: [emerg] "server" directive is not allowed here in /etc/nginx/conf.d/default.conf:1
nginx: configuration file /etc/nginx/conf.d/default.conf test failed

正确的检测修改的Nginx的语法是否错误的命令应该是:

[root@test nginx]# nginx -t -c /etc/nginx/nginx.conf 

,如果配置文件有异常,会直接报出错误

[root@test nginx]# nginx -t -c /etc/nginx/nginx.conf
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
PS:写作不易,如要转裁,请标明转载出处。
%{ comment.page.total }条评论

微信小程序:前端开发宝典

相关笔记
工具操作
  • 内容截图
  • 全屏
登录
注册
回顶部