Fork me on GitHub

编译nginx使用systemctl 开启关闭脚本

[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/apps/nginx/logs/nginx.pid 
ExecStart=/apps/nginx/sbin/nginx -c /apps/nginx/conf/nginx.conf
ExecReload=/bin/sh -c "/bin/kill -s HUP $(/bin/cat /var/run/nginx.pid)"
ExecStop=/bin/sh -c "/bin/kill -s TERM $(/bin/cat /var/run/nginx.pid)"

[Install]
WantedBy=multi-user.targe
PIDFile=/apps/nginx/logs/nginx.pid  来自于/apps/nginx/conf/nginx.conf ,nginx配置中写的pid路径是什么这里就写什么
 
posted @ 2021-07-05 14:05  Alex-Lzy  阅读(123)  评论(0编辑  收藏  举报