nginx: [emerg] “location” directive is not allowed here in 原因与解决方法

今天在修改了 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”指令

Reload service nginx... nginx: [emerg] "location" directive is not allowed here in /usr/local/nginx/conf/wp2.conf:1 done

 

原因:

这是因为我在配置文件中的位置使用了“location”指令。恰好这个location”指令在此位置是不允许使用或者说是不能识别这个指令。

 

解决方法

按照上面的原因,我去查看了我的 nginx.conf 配置文件,结果发现,我 include wp2.conf 位置放错了,这个需要放到 server 里面才对。

 

给大家看一下我配置放错的位置:

inclued wp2.conf

 

因此,我只需要把它放到正确的位置就能解决此问题了!

    A+
发布日期:2020年04月28日 11:52:51  所属分类:Nginx
最后更新时间:2020-04-28 11:52:51
付杰
  • ¥ 79.0元
  • 市场价:129.0元
  • ¥ 58元
  • 市场价:58元
  • ¥ 58.0元
  • 市场价:58.0元
  • ¥ 388.0元
  • 市场价:388.0元

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: