问题产生原因

因为 nginx 启动需要一点点时间,而 systemd 在 nginx 完成启动前就去读取 pid file

造成读取 pid 失败

解决方法

让 systemd 在执行 ExecStart 的指令后等待一点点时间即可

如果你的 nginx 启动需要时间更长,可以把 sleep 时间改长一点

建立目录

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

在新建目录中建立文件override.conf,输入内容

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

重启 daemon 和 Nginx

systemctl daemon-reload
systemctl reload nginx

Nginx启动错误 Failed to read PID from file /run/nginx.pid 的处理方法的更多相关文章

  1. centos7 nginx Failed to read PID from file /run/nginx.pid: Invalid argument 解决方法

    笔者在centos7上,配置nginx代理服务后, systemctl status nginx.service 提示错误 Failed to read PID from file /run/ngin ...

  2. nginx.service: Failed to read PID from file /run/nginx.pid: Invalid argument解决

    先附上错误信息: (myblog) root@Dapeng:/home/uwsgi# service nginx status ● nginx.service - A high performance ...

  3. nginx重启报错:nginx: [error] invalid PID number "" in "/run/nginx.pid"

    问题描述:执行 nginx -t 是OK的,然而在执行 nginx -s reload 的时候报错 nginx: [error] invalid PID number “” in “/run/ngin ...

  4. nginx: [error] invalid PID number "" in "/run/nginx.pid"

    在重启云主机(系统)之后,执行 nginx -t 是OK的,然而在执行 nginx -s reload 的时候报错 nginx: [error] invalid PID number “” in “/ ...

  5. Centos7.5中Nginx报错:nginx: [error] invalid PID number "" in "/run/nginx.pid" 解决方法

    服务器重启之后,执行 nginx -t 是OK的,然而在执行 nginx -s reload 的时候报错 nginx: [error] invalid PID number "" ...

  6. [linux] 小问题:管道符,换行问题等;[nginx]启动,重启,关闭命令;以及升级nginx切换命令

    Lniux换行问题 后面回车不会马上执行本条命令而是换行继续. : 是运行完前面就继续后面的, && 同样是前面正确就运行后面, || 是前面运行不正确就运行后面. | 管道符“|”将 ...

  7. nginx 启动错误

    场景 在Windows下 启动nginx报错: nginx: [error] ReadFile() : Incorrect function) 解决 因为 nginx.conf 中存在 /* 被认为是 ...

  8. Nginx启动错误:error while loading shared libraries: libpcre.so.0

    今天测试的时候,启动一个其他机器预编译好的nginx到目标测试机器(OEL 7.4)启动的时候,报了下列错误: /usr/local/nginx/sbin/nginx: error while loa ...

  9. Nginx启动错误:error while loading shared libraries: libpcre.so.1

    1 # /usr/local/nginx/sbin/nginx 2 /usr/local/nginx/sbin/nginx: error while loading shared libraries: ...

随机推荐

  1. webpack搭建多页面系统(一):对webpack 构建工具的理解

    为什么使用webpack构建工具? 1.开发效率方面: 在一般的开发过程中,分发好任务后,每个人完成自己单独的页面,如果有的人开发完成之后,接手别人的任务,就有可能造成开发时候的冲突. 如果利用模块化 ...

  2. jupyter notebook + MobaXterm Linux端远程部署

    $jupyter notebook --generate-config $python In []: from notebook.auth import passwd In []: passwd() ...

  3. 2、记录代码----Ajax

    $.ajax({ url:'/content-engine/index.php/tracker/confirmSendEmail', async: false, //默认为true,同意异步传输 da ...

  4. python 购物车+用户认证程序

    创建文件a.txt,b.txt.c.txt用于存放应该持续保存的信息 a.txt :用户密码输入错误3次就锁定 b.txt :购物时的活动,每个用户只能参与一次 c:txt :购物完后的发票在这里查看 ...

  5. ccf 201612-3 权限查询

     ccf 201612-3 权限查询 解题思路: 建立一个二维矩阵存储权限和角色 还差30分emmm #include<iostream> #include<cstring> ...

  6. 找出所有从根节点到叶子节点路径和等于n的路径并输出

    //找出所有从根节点到叶子节点路径和等于n的路径并输出 Stack<Node> stack = new Stack<Node>(); public void findPath( ...

  7. Python:目录

    ylbtech-Python:目录 1.返回顶部   2.返回顶部   3.返回顶部   4.返回顶部   5.返回顶部     6.返回顶部   作者:ylbtech出处:http://ylbtec ...

  8. IEDA 实现自动生成序列化号(serialVersionUID)

    完整操作流程:Setting->Editor->Inspections->Java->Serialization issues->Serializable class w ...

  9. alt + tab 替代品 switcheroo

    作为windows10 alt+tab的增强品: 分享下: 原版: https://github.com/elig0n/Switcheroo 单击版本 https://github.com/elig0 ...

  10. IPTV系统的VOD与TV业务性能测试

    IPTV的未来发展正在成为业界的焦点话题.据市场研究公司MRG的统计,全球IPTV用户将由2004年的200万增加至2010年的2000万,预计全球IPTV市场2005-2010年的复合增长率为102 ...