CentOS7 Nginx啓動腳本

1、創建腳本文件

vim /lib/systemd/system/nginx.service

2、腳本內容

Nginx的安裝路徑爲/usr/local/nginx

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

3、相關命令

  • 啓動:systemctl start nginx
  • 停止:systemctl stop nginx
  • 重啓:systemctl restart nginx
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章