创建nginx.service文件
vim /usr/lib/systemd/system/nginx.service
添加配置内容
/usr/local/nginx/sbin/nginx 是nginx启动路径,根据实际安装情况修改
[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 stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
设置开机自启
systemctl enable nginx.service
评论区