问题产生原因

因为 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. 【Amaple教程】3. 模板指令与状态数据(state)

    一个模块的template模板.JavaScript和css之间的关系其实可以如下图表示: 如果你了解Angular.Vue动态模板,那你将会对Amaple的模板感到很熟悉,在Amaple中,temp ...

  2. 20175215 2018-2019-2 第十周java课程学习总结

    第十二章 Java多线程机制 12.1 进程与线程 12.1.1 操作系统与进程 程序是一段静态的代码,它是应用软件执行的蓝本. 进程是程序的一次动态执行过程,它对应了从代码加载.执行至执行完毕的一个 ...

  3. win10无法连接windows服务器,无法连接SENS服务

    本文链接:https://blog.csdn.net/weixin_38374974/article/details/80475566 膜拜大佬 首先,进入windows界面的时候,前期加载速度变得极 ...

  4. Laravel 中如何区别 Model 或者是 Builder?

    User::where('id',1)->update([])  和  User::find(1)->update([]) 有异曲同工之效.   额? 当你通过 Laravel 与数据库交 ...

  5. HearthBuddy的狂野和休闲模式来回切换

    表现1 配置是标准,休闲模式 然后一直重复提示 select desire deck select causal mode 表现2 配置是狂野,休闲模式 然后一直提示 切换到狂野 切换到标准 把模式切 ...

  6. Breadcrumb 面包屑

    显示当前页面的路径,快速返回之前的任意页面. 基础用法 适用广泛的基础用法. 在el-breadcrumb中使用el-breadcrumb-item标签表示从首页开始的每一级.Element 提供了一 ...

  7. java.sql.SQLException: Listener refused the connection with the following error: ORA-12505, TNS:list

    package DisplayAuthors; import  java.sql.*; public class DisplayAuthors  { private static final  Str ...

  8. 数据中心网络架构的问题与演进 — CLOS 网络与 Fat-Tree、Spine-Leaf 架构

    目录 文章目录 目录 前文列表 CLOS Networking Switch Fabric 胖树(Fat-Tree)型网络架构 Fat-Tree 拓扑示例 Fat-Tree 的缺陷 叶脊(Spine- ...

  9. 2019.11.10【每天学点SAP小知识】Day3 - ABAP 7.40新语法 值转化和值赋值

    1.语法为 CONV dTYPE|#(...)\ # 代表任意类型 "7.40之前表达式 . DATA helper TYPE string. DATA xstr TYPE xstring. ...

  10. 利用python列出当前目录下的所有文件

    问题 当一个目录下有很多文件夹或者文件,我们想分析各个文件的名字,这时就可以写一个函数,列出当前目录下所有文件名字. 代码 src_dir = r'./' # 源文件目录地址 def list_all ...