linux - nginx automatically terminates after starting for a while
大家讲道理
大家讲道理 2017-05-16 13:26:37
0
1
1249

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
大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(1)
某草草

I am speechless, point the PID file to

After

PIDFile=/var/run/nginx/nginx.pid
, it turned out normal.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template