首頁  >  問答  >  主體

linux - nginx 啟動一會就自動終止了

nginx 在CentOS 7.3 下編譯安裝的,使用systemctl start nginx 命令啟動nginx,啟動成功後,可以正常訪問,但是沒一會兒就不能訪問,看後台發現nginx 進程已經沒了,看錯誤日誌,也沒有錯誤。 使用 nginx 指令啟動 nginx,就沒有這個問題,無言了。

/usr/lib/systemd/system/nginx.service

檔案是手動建立的,內容如下:

[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
大家讲道理大家讲道理2713 天前1217

全部回覆(1)我來回復

  • 某草草

    某草草2017-05-16 13:28:37

    無言了,把PID檔指向

    PIDFile=/var/run/nginx/nginx.pid
    後,居然正常了。

    回覆
    0
  • 取消回覆