84

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

4

2 回答 2

154

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

events {}
http {
    server {
        # Your code here
    }
}
于 2019-06-17T12:36:56.680 回答
7

放在 http{} 上面

events {
    worker_connections 1024;
}

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

于 2021-08-07T17:47:51.897 回答