- vim /usr/lib/systemd/system/nginx.service 写入以下内容
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c /root/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
- 重新加载配置
sudo systemctl daemon-reload
- 设置开机自启
systemctl enable nginx.service
网友评论