[错误]|nginx: [error] invalid PID number "" in "/usr/local/nginx-1.12.2/nginx_my.pid"

nginx: [error] invalid PID number “” in “/usr/local/nginx-1.12.2/nginx_my.pid”

nginx: [error] invalid PID number “” in “/usr/local/nginx-1.12.2/nginx_my.pid”
翻译:nginx:[错误]无效的PID编号 “” 在 “/usr/local/nginx-1.12.2/nginxmy.PID”中。
即:在这个文件中PIID编号空字符串

what?:场景再现

停止(stop)了nginx服务,然后自己照着nginx.conf文件,自己写了一个nginx-my.conf文件。接着我就测试我的文件nginx-my.conf 正确性,在用我写的配置文件nginx-my.conf重启(reload) nginx。结果就报这个错误。

好,那我们来分析一下它为什么会发生呢?

why?:什么原因

在nginx处于stop状态时,我用了reload来启动nginx。
注意 : nginx -s reload仅用于告诉正在运行的nginx进程重新加载其配置。在停止之后,您没有正在运行的nginx进程向其发送信号。 所以会报错。

那我就来验证一下我的想法。
来看一下,我们可以先查询一下nginx的进程 是否真的已经启动?

[root@wcl nginx]# ps -ef |grep nginx
 root      8837  8132  0 10:12 pts/0    00:00:00 grep --color=auto nginx     

可以从上面这段指令看出:我没有nginx启动,即nginx现在处于停止(stop)状态。

How?:如何解决

先启动nginx 才能用reload
指令:./sbin/nginx -c conf/nginx-my.conf 启动nginx

需要先启动nginx 才能用reload

[root@wcl nginx]#  ./sbin/nginx  -c conf/nginx-my.conf    //  首次启动nginx
[root@wcl nginx]# ps -ef |grep nginx      //  查看进程nginx  确实能查到 说明 启动成功
root      8840     1  0 10:12 ?        00:00:00 nginx: master process ./sbin/nginx -c conf/
nginx-my.conf
root      8841  8840  0 10:12 ?        00:00:00 nginx: worker process
root      8842  8840  0 10:12 ?        00:00:00 nginx: worker process
root      8843  8840  0 10:12 ?        00:00:00 nginx: worker process
root      8844  8840  0 10:12 ?        00:00:00 nginx: worker process
root      8846  8132  0 10:12 pts/0    00:00:00 grep --color=auto nginx
[root@wcl nginx]# ./sbin/nginx -s reload -c conf/nginx-my.conf // 这时候 我们才能重新启动nginx

总结:nginx -s reload仅用于告诉正在运行的nginx进程重新加载其配置。在停止之后,您没有正在运行的nginx进程向其发送信号,所以才会出错,找不到这个nginx_my.pid中的PID。只需运行nginx(nginx -c / path / to / config /文件) ,才会产生进程号PID.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值