重啟了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配置文件的路徑)
