2017-03-19 45 views
1

我嘗試重新啓動Ubuntu的16.04上的Apache服務,但我不能因爲端口'80'是由nginx監聽。 但是當我試圖阻止nginx時,找不到該服務。nginx啓動,但沒有找到在Ubuntu的服務

netstat -ltnp | grep ':80' 
tcp  0  0 0.0.0.0:80    0.0.0.0:*    LISTEN  6069/nginx 


    systemctl status nginx 
● nginx.service 
    Loaded: not-found (Reason: No such file or directory) 
    Active: inactive (dead) 

service nginx stop 
Failed to stop nginx.service: Unit nginx.service not loaded. 

那麼,如何停止nginx以重新啓動Apache?

感謝您的幫助

回答

0

nginx的你的機器上用其他的方式開始,然後systemd標準nginx的服務。

[email protected]:~$ ps aux | grep nginx 
root  2668 0.0 0.0 41040 928 ?  Ss 12:33 0:00 nginx: master process /usr/local/openresty/bin/openresty -p /usr/local/openresty/nginx/ 
nobody 2669 0.0 0.0 41040 3316 ?  S 12:33 0:00 nginx: worker process 

將向您顯示使用命令行參數運行nginx的完整路徑。這裏是我的電腦的例子(我使用Openresty軟件包,因此您的路徑可能會有所不同)。

現在看看nginx主進程的命令行參數。如果-p存在,則應該使用完全相同的方法來停止nginx。對於我來說,它應該是:

/usr/local/openresty/bin/openresty -p /usr/local/openresty/nginx/ -s stop 

如果-p被錯過了,你可能只是

/usr/local/openresty/bin/openresty -s stop 

將停止nginx的,但你的電腦上的nginx配置爲運行不會有可能標準服務,例如手寫系統單元。 因此,在每次重新啓動時,您都會讓nginx重新運行。