今天在修改了 nginx.conf 配置文件的时候,结果重启加载配置,报了如下错误:
Reload service nginx... nginx: [emerg] "location" directive is not allowed here in /usr/local/nginx/conf/wp2.conf:1 done
中文翻译
重新加载服务nginx ... nginx:在/usr/local/nginx/conf/wp2.conf:1done中不允许使用[emerg]“location”指令
原因:
这是因为我在配置文件中的位置使用了“location”指令。恰好这个location”指令在此位置是不允许使用或者说是不能识别这个指令。
解决方法
按照上面的原因,我去查看了我的 nginx.conf 配置文件,结果发现,我 include wp2.conf 位置放错了,这个需要放到 server 里面才对。
给大家看一下我配置放错的位置:
因此,我只需要把它放到正确的位置就能解决此问题了!