nginx is compiled and installed under CentOS 7.3. Use the systemctl start nginx command to start nginx. After the startup is successful, you can access it normally, but you cannot access it after a while. Looking at the background, you find that the nginx process has disappeared. Looking at the error log, you can also No errors. Use the nginx command to start nginx, and there will be no such problem. I am speechless.
/usr/lib/systemd/system/nginx.service
The file is created manually and has the following content:
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/run/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /etc/nginx/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reopen
ExecStop=/usr/local/nginx/sbin/nginx -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
I am speechless, point the PID file to
After