nginx: [error] invalid PID number ““ in “/data/nginx/logs/nginx.pid“

After modifying the configuration file, nginx: [error] invalid PID number “” in/data/nginx/logs/nginx. PID “appears during restart. This means that a valid PID (process number) cannot be found in the file/data/nginx/logs/nginx. PID

Solution 1: find the PID of nginx’s main process number, write it into nginx.pid file, and restart nginx

[root@yzil ~]# nginx -s reload
nginx: [error] invalid PID number "" in "/data/nginx/logs/nginx.pid"
[root@yzil ~]# ps aux | grep "nginx: master" | grep -v pts | awk '{print $2;}'
2847
[root@yzil ~]# ps aux | grep "nginx: master" | grep -v pts | awk '{print $2;}' > /data/nginx/logs/nginx.pid
[root@yzil ~]# nginx -s reload
[root@yzil ~]# 

Solution 2: kill the nginx main process and restart nginx

[root@yzil ~]# killall nginx
[root@yzil ~]# nginx

 

Read More: