Tag Archives: Nginx Startup Error

[Solved] Nginx Startup Error: directive is not allowed here in

Problem scenario

In the Linux system, the conf folder is provided in the nginx installation package by default and the configuration file of nginx.conf includes the configuration articles in this folder by default.

I use the windows system this time, and also configures the include folder through the example. However, for the convenience of the figure, the include folder and the folder of nginx.conf file are consistent.

Analyze and solve:

Nginx error log prompt:

“worker_processes” directive is not allowed here in D:/nginx-1.22.0/conf/nginx. conf:3

After deleting the worker_processes instruction, an error is reported that other instructions are not allowed.

Later, it was found that the use of wildcards in include led to the inclusion of yourself. You can modify the include method.

Nginx Startup Error: “/var/run/nginx/nginx.pid” failed” [How to Solve]

problem:

  After restarting the virtual machine, restarting nginx again will report an error: open() “/var/run/nginx/nginx.pid” failed (2: No such file or directory)

Solution:

  (1) Enter the cd /usr/local/nginx/conf/ directory and edit the configuration file nginx.conf;

  (2) There is a comment in the configuration file: #pid logs/nginx.pid;

 (3) Release the comment and modify it to: pid /usr/local/nginx/logs/nginx.pid;

  (4) Create a logs directory under the /usr/local/nginx directory: mkdir /usr/local/nginx/logs

  (5) Start nginx service: /usr/local/nginx/sbin/nginx