CentOS 7下使用systemctl為Nginx啟用進(jìn)程守護(hù)實(shí)現(xiàn)開(kāi)機(jī)自啟
1、cd到指定目錄
cd /usr/lib/systemd/system
2、創(chuàng)建nginx.service
vi nginx.service
3.輸入以下內(nèi)容,路徑為nginx安裝路徑
[Unit] Description=nginx - high performance web server Documentation=http://nginx.org/en/docs/ After=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 -c /usr/local/nginx/conf/nginx.conf ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
設(shè)置開(kāi)機(jī)啟動(dòng)
systemctl enable nginx
其它命令
#重啟應(yīng)用 systemctl restart nginx #停止應(yīng)用 systemctl stop nginx #查看應(yīng)用的日志 systemctl status nginx
本文來(lái)自博客園,作者:一事冇誠(chéng),轉(zhuǎn)載請(qǐng)注明原文鏈接:http://www.rzrgm.cn/ysmc/p/12107511.html

浙公網(wǎng)安備 33010602011771號(hào)