linux - nginx 启动一会就自动终止了

浏览:33日期:2022-08-08

问题描述

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=forkingPIDFile=/usr/local/nginx/run/nginx.pidExecStartPre=/usr/local/nginx/sbin/nginx -t -c /etc/nginx/nginx.confExecStart=/usr/local/nginx/sbin/nginx -c /etc/nginx/nginx.confExecReload=/usr/local/nginx/sbin/nginx -s reopenExecStop=/usr/local/nginx/sbin/nginx -s stopPrivateTmp=true[Install]WantedBy=multi-user.target

问题解答

回答1:

无语了,把PID文件指向

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

相关文章: