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生成不了。