在 /etc/init.d/目錄下新建乙個nginx指令碼檔案
執行指令 vi /etc/init.d/nginx 寫好指令碼後,:wq儲存退出
給檔案增加可執行許可權 chmod +x nginx
切換到 /etc/init.d/下
建立軟連線
sysv-rc-conf nginx on
重啟系統後 nginx將自動啟動
以下為nginx腳步內容 指令碼頭部的變數可能因系統的不同需要修
#! /bin/sh
# author: rui ding
# modified: geoffrey grosenbach
# modified: clement nedelcu
# reproduced with express authorization from its contributors
set -e
path=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
desc="nginx daemon"
name=nginx
daemon=/usr/local/nginx/sbin/$name
scriptname=/etc/init.d/$name
# if the daemon file is not found, terminate the script.
test -x $daemon || exit 0
d_start()
d_stop()
d_reload()
case "$1" in
start)
echo -n "starting $desc: $name"
d_start
echo "."
;;stop)
echo -n "stopping $desc: $name"
d_stop
echo "."
;;reload)
echo -n "reloading $desc configuration..."
d_reload
echo "reloaded."
;;restart)
echo -n "restarting $desc: $name"
d_stop
# sleep for two seconds before starting again, this should give the
# nginx daemon some time to perform a graceful stop.
sleep 2
d_start
echo "."
;;*)
echo "usage: $scriptname " >&2
exit 3
;;esac
exit 0
Nginx怎麼開機自啟呢
vim etc rc.d rc.local在檔案最後加上下邊這句話 usr local nginx sbin nginx start注意 格式 nginx的安裝路徑的sbin nginx的啟動命令 如果你啟動nginx的命令是 nginx start nginx的安裝路徑的sbin nginx的啟動...
windows設定nginx開機自啟
建立nginx service.exe.config 為支援net 4.0 runtime,預設只支援net 2.0 runtime 檔案結構如下 nginx service.xml檔案內容如下 自己修改對於的路徑即可 nginx nginx service high performance ngi...
frp Linux centos7 開機自動啟動
建立檔案 vim usr lib systemd system frpc.service新增如下內容 unit description frapc client after network.target syslog.target wants network.target service type ...