編寫Nginx啟停服務指令碼

2021-09-08 12:09:04 字數 793 閱讀 3935

在/etc/init.d/目錄下建立指令碼

vim  /etc/init.d/nginx
編寫指令碼內容:(其中下面2行需要根據情況自行修改)

nginxd=/

opt/

nginx

/sbin

/nginx

nginx_config=/

opt/

nginx

/conf

/nginx.conf

更改指令碼許可權

chmod 777 /etc/init.d/nginx
測試

service nginx start 或/etc/init.d/nginx start
開機啟動

chkconfig --list|grep nginx chkconfig --add nginx
chkconfig --list|grep nginx nginx           0:關閉    1:關閉    2:關閉    3:關閉    4:關閉    5:關閉    6:關閉 # chkconfig --level 2345 nginx on # chkconfig --list|grep nginx nginx           0:關閉    1:關閉    2:啟用    3:啟用    4:啟用    5:啟用    6:關閉
或將此命令加入到rc.local檔案中,這樣開機的時候nginx就預設啟動了

vi /etc/rc.local
加入一行 /etc/init.d/nginx start 儲存並退出,下次重啟會生效。

編寫Nginx啟停服務指令碼

在 etc init.d 目錄下建立指令碼 vim etc init.d nginx編寫指令碼內容 其中下面2行需要根據情況自行修改 nginxd opt nginx sbin nginx nginx config opt nginx conf nginx.conf 更改指令碼許可權 chmod 7...

nginx啟停指令碼

安裝nginx時,原始碼包中未帶官方的啟動指令碼,也就無法使用service nginxd start這種啟動方式,查了下資料自己寫了乙個 bin bash version 0.0.1 author lifafu file time 2017 02 04 08 00 company source e...

Nginx服務的啟停控制

如 kill quit 主程序號 注 平緩停止 nginx服務在執行時,會儲存乙個主程序和乙個或多個worker process工作程序。我們通過給nginx 服務的主程序傳送訊號就可以控 務的啟停了。首先需要知道主程序的程序號pid。獲取pid途徑 1.nginx伺服器安裝目錄下的logs目錄中會...