Nginx pid文件找不到 nginx: [error] open() "/run/nginx/nginx.pid" failed (2: No such file or directory)

Nginx pid文件找不到

nginx: [error] open() "/run/nginx/nginx.pid" failed (2: No such file or directory)

原因:pid被误删除或者不存在

解决如下:停掉目前的nginx服务,重启nginx,生成新的pid文件

1. 查看nginx服务所占用的进程

/run/nginx # ps
PID   USER     TIME  COMMAND
    1 root      0:00 /bin/sh
   23 root      0:00 [nginx]
   28 root      0:00 [nginx]
  132 root      0:00 nginx: master process nginx
  190 nginx     0:00 nginx: worker process
  206 root      0:00 sh
  245 root      0:00 ps

2. 杀死进程

/run/nginx # kill 132
/run/nginx # ps
PID   USER     TIME  COMMAND
    1 root      0:00 /bin/sh
   23 root      0:00 [nginx]
   28 root      0:00 [nginx]
   29 root      0:00 sh
   35 root      0:00 [nginx]
   36 root      0:00 sh
  206 root      0:00 sh
  246 root      0:00 ps

3. 重启nginx

/run/nginx # nginx
/run/nginx # ls
nginx.pid # 该文件已生成
  • 注意:查看nginx的pid文件生成存放目录,如没有设置则可设置,在nginx.conf配置文件中设置,目录不存在,则需要创建该目录,否则重启的时候pid生成不了。

猜你喜欢

转载自www.cnblogs.com/will-xz/p/13394669.html