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

问题描述

参考文章:nginx: [error] invalid PID number “” in “/usr/local/nginx/logs/nginx.pid”

  1. 编译安装完 nginx 后,启动 nginx时,出现nginx已经在运行,即nginx: [emerg] bind() to 0.0.0.0:82 failed (98: Address already in use)。然后输入./nginx -s reload时,出现了nginx: [error] invalid PID number “” in “/usr/local/nginx/logs/nginx.pid”的报错。
  2. 进程还在,没有干掉。却把进程的文件删除了,就会出现这种deleted,不正常进程。

在这里插入图片描述


原因分析:

卸载 nginx 前,没有关闭 nginx,导致 nginx 的内容都被删除了, nginx 的进程还保留在虚拟机中。


知识拓展:

1.如何查看nginx的进程

进程:正在运行的程序/脚本。每个进程会有对应的编号——进程号,唯一识别这个进程是谁。

1)ps -ef

  • 查看系统所有进程
[root@test1 ~]# ps -ef
  • 选择只看 nginx 的进程
[root@test1 ~]# ps -ef|grep nginx

nginx是多进程的程序。

在这里插入图片描述

2)top命令

  • top命令看到的pid 进程号
[root@test1 ~]# top

在这里插入图片描述

  • top命令后,按1看cpu是几核的。(下图说明这个cpu是2核的。)

在这里插入图片描述

  • 看cpu是几核的另一个命令:lscpu
[root@test1 ~]# lscpu

在这里插入图片描述

3)LSOF

  • lsof 查看某个端口号对应的进程信息
[root@test1 ~]# lsof -i:98

2.如何查看一个进程的执行路径

  • pwdx:来查看进程号(PID)对应的执行路径
[root@test1 ~]# pwdx pid

在这里插入图片描述

解决方法:

[root@test1 ~]# ps -ef|grep nginx
root       1486      1  0 14:15 ?        00:00:00 nginx: master process ./nginx
nobody     1487   1486  0 14:15 ?        00:00:00 nginx: worker process
root       1807   1789  0 16:06 pts/1    00:00:00 grep --color=auto nginx
[root@test1 ~]# killall -9 nginx
[root@test1 ~]# cd /usr/local/nginx/sbin/
[root@test1 sbin]# ./nginx

kill -9 pid”:强制杀死进程。
-9:强制执行。

  • 6
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
在这个错误信息中,"nginx: [error] invalid PID number "/usr/local/nginx/logs/nginx.pid"",它是由于nginx在加载配置文件时遇到了无效的进程ID号。而具体原因是由于nginx在重新读取配置文件时,检测到指定的进程ID文件"/usr/local/nginx/logs/nginx.pid"无效或不存在。解决方法是检查"/usr/local/nginx/logs/nginx.pid"文件是否存在,如果不存在,则需要手动指定nginx配置文件的路径来启动nginx,即使用命令"/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf"。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [nginx: [error] invalid PID number ; in /usr/local/nginx/logs/nginx.pid](https://blog.csdn.net/qq_25288617/article/details/124607984)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [解决 nginx: [error] invalid PID number "" in "/usr/local/nginx/logs/nginx.pid](https://blog.csdn.net/cxs123678/article/details/80201412)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

BW_doubleD

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值