我可以在安装nginx后访问nginx欢迎页面。但是,当我运行systemctl status nginx
时,我收到此警告:
systemd [1]:无法从文件/run/nginx.pid读取PID:无效 参数
您能否告诉我导致此问题的原因以及如何解决?感谢。
详细回复信息:
nginx.service - The nginx HTTP and reverse proxy server Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2017-03-02 06:43:24 CST; 2s ago Process: 24007 ExecReload=/bin/kill -s HUP $MAINPID (code=exited, status=0/SUCCESS) Process: 8377 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS) Process: 8374 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS) Process: 8373 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS) Main PID: 8380 (nginx) CGroup: /system.slice/nginx.service |-8380 nginx: master process /usr/sbin/ngin `-8381 nginx: worker proces Mar 02 06:43:24 VM_134_114_centos systemd[1]: Starting The nginx HTTP and reverse proxy server... Mar 02 06:43:24 VM_134_114_centos nginx[8374]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok Mar 02 06:43:24 VM_134_114_centos nginx[8374]: nginx: configuration file /etc/nginx/nginx.conf test is successful Mar 02 06:43:24 VM_134_114_centos systemd[1]: Failed to read PID from file /run/nginx.pid: Invalid argument Mar 02 06:43:24 VM_134_114_centos systemd[1]: Started The nginx HTTP and reverse proxy server.
答案 0 :(得分:3)
我认为你没有解决它。
首先,请注意在Nginx启动之前有意删除PID文件。您可以在发布的输出中看到:
ExecStartPre=/usr/bin/rm -f /run/nginx.pid
为什么呢?答案是Nginx service file:
中的评论# Nginx will fail to start if /run/nginx.pid already exists but has the wrong
# SELinux context. This might happen when running `nginx -t` from the cmdline.
# https://bugzilla.redhat.com/show_bug.cgi?id=1268621
ExecStartPre=/usr/bin/rm -f /run/nginx.pid
因此,如果Nginx正常运行并且您可以停止/启动它,我认为您可以在日志中忽略该警告。
答案 1 :(得分:0)
重新启动服务器为我解决了错误。不漂亮,但它有效。