
我剛剛在 Ubuntu 16.04 上安裝了 nginx。問題是,我只想手動啟動它,而不想在運行級別自動啟動它。
我發現了很多關於如何讓它在不同的運行級別上運行的條目,但不阻止在所有運行級別上運行。
所以,我猜測並這樣做了:
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start:
# Default-Stop: 0 1 2 3 4 5 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFO
然後:
/etc/init.d$ sudo update-rc.d nginx defaults
insserv: warning: current start runlevel(s) (2 3 4 5) of script `nginx' overrides LSB defaults (empty).
insserv: warning: current stop runlevel(s) (0 1 6) of script `nginx' overrides LSB defaults (0 1 2 3 4 5 6).
在我看來,我的更改不起作用。
我該如何關閉它?
答案1
此答案假設您使用 16.04 中的預設 init 系統,即 SystemD。
借用自DigitalOcean 的 SystemD 指南,您可以使用以下命令停用 nginx 自動啟動:
sudo systemctl disable nginx.service
這應該像提供的舊功能一樣禁用服務在啟動時自動啟動update-rc.d
。 (請注意,對於 SystemD,update-rc.d
不會那麼有用)