2016-04-21 161 views
0

所以Nginx的是守護進程模式,但根開始,因爲證實了這一命令:/etc/init.d/nginx重新啓動作爲root失敗,但nginx的-t不會告訴任何

[email protected]:/home/vagrant# ps -edf | grep nginx 
root  7331  1 0 13:42 ?  00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on; 
www-data 7333 7331 0 13:42 ?  00:00:00 nginx: worker process 

但是,如果我:

[email protected]:/home/vagrant# /etc/init.d/nginx restart 
* Restarting nginx nginx [fail] 

但是當我運行:

[email protected]:/home/vagrant# nginx -t 
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok 
nginx: configuration file /etc/nginx/nginx.conf test is successful 

只有當我回去用戶vagrant,我得到:

[13:46:58] [email protected]:/home/vagrant $ nginx -t 
2016/04/21 13:47:01 [emerg] 7390#7390: open() "/run/nginx.pid" failed (13: Permission denied) 

如果我:

[email protected]:/home/vagrant# ls -l /run/nginx.pid 
-rw-r--r-- 1 root root 5 Apr 21 13:45 /run/nginx.pid 

那麼,爲什麼不會nginx的重啓?我究竟做錯了什麼?我的意思是,root沒有足夠的權限沒有意義,是嗎?

以及sudo nginx -t怎麼不顯示任何錯誤信息?

+0

您可以使用此解決方案解決問題http://serverfault.com/a/265626 –

回答

0

在配置文件user www www;中有這條指令嗎?

如果是,那麼用戶www(或者你設置的人)有機會獲得PID文件並向站點目錄

額外:如果您需要,您可以使用pid path;指令移動pif文件