Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx startup prompt [emerg] no "events" section in configuration

In the X-WAF deployment, you need to create a new nginx configuration file. However, when testing the nginx configuration, an error is found and nginx cannot be started.

I refer to http://blog.51cto.com/14071176/2318054,I did it step by step according to the configuration in the article, but I had a problem.

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 

Under normal circumstances, executing /usr/local/openresty/nginx/sbin/nginx -t will have two successes, but mine is a success and a failure.

like image 204
Dora Avatar asked Feb 01 '19 14:02

Dora


People also ask

How enable conf file in nginx?

We can enable a server block's configuration file by creating a symbolic link from the sites-available directory to the sites-enabled directory, which Nginx will read during startup. To do this, enter the following command: sudo ln -s /etc/nginx/sites-available/ example.com /etc/nginx/sites-enabled/

What is the default nginx config?

The way nginx and its modules work is determined in the configuration file. By default, the configuration file is named nginx. conf and placed in the directory /usr/local/nginx/conf , /etc/nginx , or /usr/local/etc/nginx .

How do I start Openresty?

To start your OpenResty®, you can just use the openresty command in place of your original nginx command as long as you have correctly added the <openresty-prefix>/bin/ directory to your system environment PATH ( <openresty-prefix> is default to /usr/local/openresty/ unless being overridden by ./configure 's --prefix= ...

What command is used to test your nginx server configuration file?

Through a simple command you can verify the status of the Nginx configuration file: $ sudo systemctl config nginx The output will show if the configuration file is correct or, if it is not, it will show the file and the line where the problem is.


2 Answers

Just add events { } above the http { line:

events {} http {     server {         # Your code here     } } 
like image 100
Stepan Suvorov Avatar answered Sep 19 '22 16:09

Stepan Suvorov


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.

like image 40
Dylan B Avatar answered Sep 18 '22 16:09

Dylan B