Tag Archives: open() “/opt/Nginx/nginx/nginx.pid” failed (2: No such file or directory)

[Solved] Nginx Log Error: open() “/opt/Nginx/nginx/nginx.pid” failed (2: No such file or directory)

After nginx is started successfully, it cannot be accessed

Check that nginx.pid does not have a port number, but the startup is normal,

[ root@rzk nginx]# ./nginx -t

nginx: the configuration file /opt/Nginx/nginx/nginx.conf syntax is ok

nginx: configuration file /opt/Nginx/nginx/nginx.conf test is successful

Check the logs. Error.log to confirm the errors in these lines

2021/11/22 17:26:51 [error] 188975#0: open() “/opt/Nginx/nginx/nginx.pid” failed (2: No such file or directory)

2021/11/22 17:27:07 [notice] 188978#0: signal process started

2021/11/22 17:27:07 [error] 188978#0: invalid PID number “” in “/opt/Nginx/nginx/nginx.pid”

Solution (I)

/Opt/nginx/nginx/nginx.pid check whether the file exists. If not, create a new MKDIR nginx.pid, save and exit

If the above problems cannot be solved

Solution (II)

Open comment

Enter the configuration file VIM/opt/nginx/nginx/nginx. Conf

Look at line 7 and you can see that the PID is annotated

Modify PID storage path

It can be modified to PID/opt/nginx/nginx/nginx.pid; Here I exist under the nginx root path

After saving, execute the following command. Because/opt/nginx/nginx/nginx.pid is opened, the execution configuration file will generate the corresponding nginx. PID

-C specify a file, that is, specify the accessory file

[root@rzk nginx]# ./nginx -c /opt/Nginx/nginx/nginx.conf  # If you want to specify a configuration file to start then use the following command,
[root@rzk nginx]# cat nginx.pid View pid
189585

Then you can check the nginx startup