【问题标题】:Nginx startup prompt [emerg] no "events" section in configurationNginx 启动提示 [emerg] 配置中没有“事件”部分
【发布时间】:2019-06-26 03:27:45
【问题描述】:

在X-WAF部署中,需要新建一个nginx配置文件。但是在测试nginx配置的时候,发现报错,无法启动nginx。

我参考http://blog.51cto.com/14071176/2318054,我按照文章中的配置一步步做了,但是遇到了问题。

root@VM-0-6-ubuntu:~# /usr/local/openresty/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/openresty/nginx/conf/nginx.conf syntax is ok
nginx: [emerg] no "events" section in configuration
nginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test failed

root@VM-0-6-ubuntu:~# /usr/local/openresty/nginx/sbin/nginx
nginx: [emerg] no "events" section in configuration

正常情况下,执行/usr/local/openresty/nginx/sbin/nginx -t 会成功两次,而我的是成功和失败。

【问题讨论】:

  • 只需在http { 行上方添加events { }
  • 谢谢,我使用另一个网站的 nginx.conf 配置文件来解决这个问题。确实是nginx.conf的问题。我指的另一个站点是kongdewei.cn/2017/08/11/…

标签: nginx openresty web-application-firewall


【解决方案1】:

只需在http { 行上方添加events { }

events {}
http {
    server {
        # Your code here
    }
}

【讨论】:

【解决方案2】:

放在http上面{}

events {
    worker_connections 1024;
}

Nginx worker_connections : 设置一个工作进程可以同时打开的最大连接数。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-16
    • 1970-01-01
    • 2016-08-16
    • 2010-12-24
    • 2021-08-30
    • 2014-08-06
    相关资源
    最近更新 更多