Nginx Failed to parse PID from file

转自 Failed to parse PID from file · Nginx 教程 · 看云

记录下问题解决方案

以下是有关如何修复错误消息的提示:

nginx.service: Failed to read PID from file /run/nginx.pid: Invalid argument
或者
openresty.service: Failed to parse PID from file /run/openresty.pid: Invalid argument

此行为是一个已知错误,由nginx和systemd之间的竞争条件引起。 Systemd期望在nginx有时间创建之前填充PID文件。要修复错误,您必须创建该文件。

Step 1. 创建目录:/etc/systemd/system/nginx.service.d

Create a directory named nginx.service.d in /etc/systemd/system/:

mkdir /etc/systemd/system/nginx.service.d

Step 2. Print data to file

printf "[Service]\nExecStartPost=/bin/sleep 0.1\n" > /etc/systemd/system/nginx.service.d/override.conf

确保在其自己的行上输入>之后的字符串,以便printf将其输出写入配置文件:

 /etc/systemd/system/nginx.service.d/override.conf

Step 3. Reload the daemon

Reload systemd manager configuration:

systemctl daemon-reload

This will rerun all generators, reload all unit files and recreate the entire systemd dependency tree.

Step 4. Restart NGINX

This line will restart NGINX for you:

systemctl restart nginx

The error should be fixed now.

An alternative workaround

Another workaround is removing the PIDFile option and adding the line:

ExecStopPost=/bin/rm -f /run/nginx.pid
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值