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

在 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 会有两次成功,但是我的成功和失败。

66840 次浏览

Just add events { } above the http { line:

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

Put above http{}

events {
worker_connections 1024;
}

Nginx worker_connections : sets the maximum number of simultaneous connections that can be opened by a worker process.