编写nginx.service文件
vim /etc/systemd/system/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 start nginx.service
systemctl enable nginx.service