
我正在Ubuntu 上設定Nginx 和OpenRusty,有一點讓我困惑的是,即使在我退出OpenRusty 並停止Nginx 後,我仍然可以觀察到nginx 正在運行,似乎這個進程甚至無法被殺死,我的問題是誰啟動了這個nginx 以及為什麼這個 nginx 守護程式總是在運行?
ps -aux | grep nginx
root 3779 0.0 0.0 10776 6180 ? Ss 06:57 0:00 **nginx: master process nginx -g daemon off;**
systemd+ 4587 0.0 0.0 11172 2756 ? S 06:57 0:00 nginx: worker process
jia 17315 0.0 0.0 16184 1068 pts/0 S+ 07:08 0:00 grep --color=auto nginx
我嘗試 systemctl 來停止它,似乎 nginx 仍在運行
sudo systemctl stop nginx.service
sudo systemctl status nginx.service
● nginx.service - The NGINX HTTP and reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; disabled; vendor preset: enabled)
Active: inactive (dead)
sudo ps -aux | grep nginx root 3779 0.0 0.0 10776 6180 ? Ss 06:57 0:00 nginx: master process nginx -g daemon off;
systemd+ 4587 0.0 0.0 11172 2756 ? S 06:57 0:00 nginx: worker process
答案1
OpenResty(假設你的意思是 OpenRe麥粒腫而不是 OpenR你sty!) 是 nginx 的 http 守護程式的工具集和進階配置。因此,如果 openresty 正在運行,它將始終包含正在運行的 nginx。
所以對我來說你的ps -aux | grep nginx
結果是:
...
root 8402 0.0 0.0 49984 14580 ? SNs Jul25 0:00 nginx: master process /usr/local/openresty/nginx/sbin/nginx -g daemon on; master_process on;
...
我的配置似乎包含完整路徑,但如果你的配置沒有,你可以嘗試(替換8402
為你的 nginx 的 pid):
sudo ls -l /proc/8402/exe
就我而言,結果是:
lrwxrwxrwx 1 root root 0 Sep 20 16:46 /proc/8402/exe -> /usr/local/openresty/nginx/sbin/nginx
因此,正在運行的 nginx 二進位檔案來自 OpenResty,而不是「其他」nginx。您也可以考慮刪除其他 nginx,以免對正確的設定檔感到困惑...