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

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

Solution 2: kill the nginx main process and restart nginx

[[email protected] ~]# killall nginx
[[email protected] ~]# nginx

 

Read More: