linux操作系統重啟后 解決nginx的pid消失問題


重啟了linux服務器之后,進程性的 nginx -s stop后再次啟動nginx -s reload ,總是會報錯誤nginx: [error] open() "/alidata/server/nginx/logs/nginx.pid" failed (2: No such file or directory),這應該是因為把nginx進程殺死后pid丟失了,下一次再開啟nginx -s reload時無法啟動,重裝可以解決這個問題,但是太麻煩了。

 issued a nginx -s stop and after that I got this error when trying to reload it.

[error]: invalid PID number "" in "/var/run/nginx.pid"

That /var/run/nginx/pid file is empty atm.

What do I need to do to fix it?

 

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)

方法很簡單:

1.首先你要先確保關閉nginx進程了(可以通過pkill -9 nginx關閉進程)

2.進入你nginx的安裝目錄里面 cd `路徑/nginx/sbin`里面 然后輸入

>nginx/sbin/nginx -c nginx/conf/nginx.conf 就可以了(sbin目錄下面有個nginx為啟動程序,-c為以什么配置啟動,后面接着nginx配置文件的路徑)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM