编写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
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:nginx自启动通过注册系统服务实现 - Python技术站