将Nginx加入systemctl管理

cd /lib/systemd/system 
vim nginx.service   #加入内容如下
[Unit]
Description=nginx
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 daemon-reload

将Nginx加入systemctl管理_第1张图片

systemctl enable nginx  #设置开机自启

你可能感兴趣的:(Nginx,nginx,systemctl,nginx开机自启)