1. 程式人生 > >重啟nginx後丟失nginx.pid的解決方法

重啟nginx後丟失nginx.pid的解決方法

在使用的阿里雲伺服器上,程序性的 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時無法啟動,重灌可以解決這個問題,但是太麻煩了。

一開始百度解決該問題。只是找到幾個求助答案。沒有實際有效的方法,於是用google開始搜尋,雖然英語比較噁心,但一般,英文網站上總會有解決方法這一次也不另外。

 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)

於是我用了這方法,也就是nginx -c /path/to/config/file  //在我機器上是這樣的/alidata/server/nginx/sbin/nginx -c /alidata/server/nginx/conf/nginx.conf

希望可以幫助到大家,還有就是搞計算機真他媽應該學好英語啊。