centos7.x設置nginx開機自啓動

1、在 /lib/systemd/system/ 下新建 nginx.service 文件,內容如下:

[Unit]
Description=nginx service
After=network.target 
   
[Service] 
Type=forking 
ExecStart={nginx安裝目錄}/sbin/nginx
ExecReload={nginx安裝目錄}/sbin/nginx -s reload
ExecStop={nginx安裝目錄}/sbin/nginx -s quit
PrivateTmp=true 
   
[Install] 
WantedBy=multi-user.target

2、root用戶下執行

  systemctl disable nginx

3、相關控制命令

# systemctl start nginx.service          啓動nginx服務

# systemctl stop nginx.service           停止服務

# systemctl restart nginx.service        重新啓動服務

# systemctl list-units --type=service     查看所有已啓動的服務

# systemctl status nginx.service          查看服務當前狀態

# systemctl enable nginx.service          設置開機自啓動

# systemctl disable nginx.service         停止開機自啓動

轉自 https://www.cnblogs.com/jepson6669/p/9131217.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章