centos 7.2 nginx 開機啟動

nginx

vim /lib/systemd/system/nginx.service

[Unit]

Description=nginx

After=network.target

[Service]Type=forking

ExecStart=/usr/local/nginx/sbin/nginx

ExecReload=/usr/local/nginx/sbin/nginx -s reload

ExecStop=/usr/local/nginx/sbin/nginx -s quit

PrivateTmp=true

[Install]

WantedBy=multi-user.target

Description:描述服務(wù)

After:描述服務(wù)類別

[Service]服務(wù)運行參數(shù)的設(shè)置

Type=forking是后臺運行的形式

ExecStart為服務(wù)的具體運行命令

ExecReload為重啟命令

ExecStop為停止命令

PrivateTmp=True表示給服務(wù)分配獨立的臨時空間

注意:[Service]的啟動、重啟、停止命令全部要求使用絕對路徑

[Install]運行級別下服務(wù)安裝的相關(guān)設(shè)置,可設(shè)置為多用戶,即系統(tǒng)運行級別為3

保存退出。

2.設(shè)置開機啟動

systemctl enable nginx.service

3.其它命令

啟動nginx服務(wù)

systemctl start nginx.service

設(shè)置開機自啟動

systemctl enable nginx.service

停止開機自啟動

systemctl disable nginx.service

查看服務(wù)當前狀態(tài)

systemctl status nginx.service

重新啟動服務(wù)

systemctl restart nginx.service

查看所有已啟動的服務(wù)

systemctl list-units --type=service

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容