nginx centos 服務(wù)開機(jī)啟動設(shè)置實例詳解
nginx centos 服務(wù)開機(jī)啟動設(shè)置
建立服務(wù)文件
以nginx 為例
vim /lib/systemd/system/nginx.service
在nginx.service 中插入一下內(nèi)容
[Unit] Description=nginx After=network.target [Service] Type=forking ExecStart= 服務(wù)啟動命令 ExecReload= 服務(wù)重啟命令 ExecStop=服務(wù)停止命令 PrivateTmp=true [Install] WantedBy=multi-user.target
[Unit]:服務(wù)的說明
Description:描述服務(wù)
After:描述服務(wù)類別
[Service]服務(wù)運行參數(shù)的設(shè)置
Type=forking是后臺運行的形式
ExecStart為服務(wù)的具體運行命令
ExecReload為重啟命令
ExecStop為停止命令
PrivateTmp=True表示給服務(wù)分配獨立的臨時空間
注意:[Service]的啟動、重啟、停止命令全部要求使用絕對路徑
以754的權(quán)限保存在目錄:/lib/systemd/system
設(shè)置開機(jī)自啟動:
systemctl enable nginx.service
相關(guān)命令
功能 cnetos7以前 cnetos7
顯示所有已啟動的服務(wù) chkconfig --list systemctl list-units --type=service
啟動某服務(wù) service nginx start systemctl start nginx.service 或 systemctl start nginx
停止某服務(wù) service nginx stop systemctl stop nginx.service 或 systemctl stop nginx
重啟某服務(wù) service nginx restart systemctl restart nginx.service 或 systemctl restart nginx
使某服務(wù)自動啟動 chkconfig --level 3 nginx on systemctl enable nginx.service 或 systemctl enable nginx
使某服務(wù)不自動啟動 chkconfig --level 3 nginx off systemctl disable nginx.service 或 systemctl disable nginx
檢查服務(wù)狀態(tài) service nginx status systemctl is-active nginx.service (僅顯示是否)Activesystemctl status nginx.service (服務(wù)詳細(xì)信息)
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
Nginx配置HTTP強(qiáng)制跳轉(zhuǎn)到HTTPS的解決辦法
這篇文章主要給大家介紹了關(guān)于Nginx配置HTTP強(qiáng)制跳轉(zhuǎn)到HTTPS的解決辦法,當(dāng)Nginx配置https后通常需要將用戶http請求強(qiáng)制跳轉(zhuǎn)到https,需要的朋友可以參考下2023-08-08
解決Nginx + PHP(FastCGI)遇到的502 Bad Gateway錯誤
昨日,有朋友問我,他將Web服務(wù)器換成Nginx 0.6.31 + PHP 4.4.7(FastCGI)后,有時候訪問會出現(xiàn)“502 Bad Gateway”錯誤,如何解決。2009-10-10
使用Nginx+Tomcat實現(xiàn)負(fù)載均衡的全過程
很多用到nginx的地方都是作為靜態(tài)伺服器,這樣可以方便緩存那些靜態(tài)文件,比如CSS,JS,html,htm等文件,下面這篇文章主要給大家介紹了關(guān)于使用Nginx+Tomcat實現(xiàn)負(fù)載均衡的相關(guān)資料,需要的朋友可以參考下2022-05-05
實現(xiàn)Nginx中使用PHP-FPM時記錄PHP錯誤日志的配置方法
最近在本地搭建的LNMP的開發(fā)環(huán)境。為了開發(fā)的時候不影響前端的正常開發(fā)就屏蔽的PHP里面php.ini中的一些錯誤提示。但是這樣一來,就影響到了后端開發(fā)的一些問題比如不能及時調(diào)試開發(fā)中的一些問題2014-05-05
nginx 504 Gateway Time-out錯誤解決方法
我們經(jīng)常會發(fā)現(xiàn)大量的nginx服務(wù)器訪問時會提示nginx 504 Gateway Time-out錯誤了,下面我來總結(jié)了一些解決辦法,有需要了解的同學(xué)可進(jìn)入?yún)⒖?/div> 2014-11-11
nginx編譯安裝后對nginx進(jìn)行平滑升級的方法
nginx編譯安裝后用了一段時間后發(fā)現(xiàn)當(dāng)前版本有漏洞或需要新的功能時就需要對當(dāng)前nginx版本進(jìn)行版本升級,所以這時就需到對nginx的平滑升級,如何進(jìn)行平滑升級,下面就一起來了解一下2018-12-12最新評論

