centos7-nginx开机自启

cd /lib/systemd/system/
vim nginx.service

[Unit]
Description=nginx service
After=network.target 
   
[Service] 
Type=forking 
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true 
   
[Install] 
WantedBy=multi-user.target

systemctl enable nginx
systemctl daemon-reload
可重启检查状态是否生效
posted @ 2020-03-28 10:38  kylingx  阅读(911)  评论(0编辑  收藏  举报