Nginx启动提示[emerg]配置中没有“事件”部分

Dor*_*ora 15 nginx openresty web-application-firewall

在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
Run Code Online (Sandbox Code Playgroud)

在正常情况下,执行/ usr / local / openresty / nginx / sbin / nginx -t将获得两个成功,但是我的是成功和失败。

Ste*_*rov 27

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

//此评论对我有用。

  • 你知道这是做什么的吗? (34认同)
  • @BenBieler它是连接处理指令的部分。例如,worker_connections 768;http://nginx.org/en/docs/ngx_core_module.html#events (2认同)

Dyl*_*n B 26

放在 http{} 上面

events {
    worker_connections 1024;
}
Run Code Online (Sandbox Code Playgroud)

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

  • 它一定可以工作,但是如果您只想保留默认值怎么办?然后定义一个空的“events {}”部分在我看来更好。 (3认同)