一、错误场景:
使用nginx -s reload 重新加载nginx配置报错,或者启动nginx 报错
二、报错信息:
错误提示如下:
[root@nues ~]
nginx: [error] invalid PID number "" in "/run/nginx.pid"
或者
[root@nues ~]
nginx: [error] invalid PID number "" in "/usr/local/var/run/nginx/nginx.pid
三、报错分析:
错误分析: google一下 nginx -s reload is only used to tell a running nginx process to reload its config. After a stop, you don’t have a running nginx process to send a signal to. Just run nginx (possibly with a -c /path/to/config/file)
翻译过来: Nginx -s reload只用于告诉正在运行的Nginx进程重新加载它的配置。在停止之后,你没有一个正在运行的nginx进程来发送信号。只需要运行nginx(可能带有-c /path/to/config/文件)
参考资料:https://stackoverflow.com/questions/7646972/nginx-invalid-pid-number
处理方法:
处理方法1: 重新加载配置文件 nginx.conf,然后再执行 reload
[root@nues ~]
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@nues ~]
[root@nues ~]
处理方法2: 查询nginx的pid 直接写入到 /run/nginx.pid里面
[root@nues ~]
root 2716 0.0 0.0 54348 7636 ? Ss Jul03 0:00 nginx: master process nginx
root 24294 0.0 0.0 13144 1084 pts/1 S+ 10:00 0:00 grep --color=auto nginx: master process nginx
[root@nues ~]
[root@nues ~]
处理方法3(慎用):
[root@nues ~]
[root@nues ~]
|