问题产生原因

因为 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. 了解dubbo+zookeeper

    一.Dubbo是什么? Dubbo是阿里巴巴公司开源的一个高性能优秀的服务框架,使得应用可通过高性能的 RPC 实现服务的输出和输入功能,分布式服务框架(SOA),致力于提供高性能和透明化的RPC远程 ...

  2. C语言博客作业00

    对网络专业的了解 我一直觉得计算机是个很神奇的东西,就像大脑中有思想一样,在一个有形的芯片中能储存着无形的数据.它们的存储方式是什么?读取方式又是什么?为什么2个数字能产生如此巨大的信息?为什么点击鼠 ...

  3. 石川es6课程---12、Promise

    石川es6课程---12.Promise 一.总结 一句话总结: 用同步的方式来书写异步代码,让异步书写变的特别简单 用同步的方式来书写异步代码Promise 让异步操作写起来,像在写同步操作的流程, ...

  4. redis的incr和incrby命令

    Redis Incr 命令将 key 中储存的数字值增一,如果 key 不存在,那么 key 的值会先被初始化为 0 ,然后再执行 INCR 操作. Redis Incrby 命令将 key 中储存的 ...

  5. 一、基础篇--1.2Java集合-HashMap死循环问题

    为什么HashMap会出现死循环 首先,我们知道java的HashMap不是线程安全的.多线程下应该使用ConcurrentHashMap. HashMap底层是基于动态数组和单向链表(JDK1.7, ...

  6. centos 6和centos7关闭防火墙的方法

    centos 6 关闭命令:  service iptables stop 永久关闭防火墙:chkconfig iptables off 两个命令同时运行,运行完成后查看防火墙关闭状态         ...

  7. 原来项目更换svn地址

    近期公司由于旧地址装修,临时更换办公地址:同时相应的网络地址也更换了.我们开发项目的svn地址根目录也得改变.所以怎么解决呢? 1.找到项目根文件夹: 右键:

  8. java基础点<一>

    1. 九种基本数据类型的大小,以及他们的封装类.byte,short,int,long,boolue,float,double,char,特殊voidByte,Short,Integer,Long,B ...

  9. openerp学习笔记 单据自动编号(编码规则)

    说明: 单据自动编码允许定义 单据前缀+按当前年.月.日.时.分.秒+流水号+单据后缀 单据自动编号允许按所有公司统一编号或按分公司单独编号 单据自动编号中的流水号部分未按月重新编号,不断累计,当超出 ...

  10. 系统启动热键(Boot Hotkey)

    1.HP ENVY 13 F1 --> 系统信息F2 --> 系统检测F9 --> 启动设备选项F10 --> 设置BIOSF11 --> 系统恢复ENTER --> ...