保存下面的配置到 /lib/systemd/system/Nginx.service
[Unit]
Description=The Nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/Nginx/logs/Nginx.pid
ExecStartPre=/usr/local/Nginx/sbin/Nginx -t
ExecStart=/usr/local/Nginx/sbin/Nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
设置Nginx为开机启动项
systemctl enable Nginx.service
原文链接:/systemd/414631.html