zoukankan      html  css  js  c++  java
  • nginx的问题?

    现象:

    nginx restart 超时
    nginx stop之后,80端口仍然被占用
    在 kill调进程之后再启动
    查看 systemctl status nginx

    systemd[1]: Failed to read PID from file /run/nginx.pid: Invalid argument
    

    百度结果:

    Failed to read PID from file

    因为 nginx 启动需要一点点时间,而 systemd 在 nginx 完成启动前就去读取 pid file
    造成读取 pid 失败
    
    解决方法很简单,让 systemd 在执行 ExecStart 的指令后等待一点点时间即可
    如果你的 nginx 启动需要时间更长,可以把 sleep 时间改长一点
    
    mkdir -p /etc/systemd/system/nginx.service.d
    printf "[Service]
    ExecStartPost=/bin/sleep 0.1
    " > /etc/systemd/system/nginx.service.d/override.conf
    
    然后
    systemctl daemon-reload
    systemctl restart nginx.service
    

    结果

    [root@yumsources yum]# systemctl status nginx
    ● nginx.service - The nginx HTTP and reverse proxy server
       Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
      Drop-In: /etc/systemd/system/nginx.service.d
               └─override.conf
       Active: active (running) since Sat 2020-06-27 16:50:21 CST; 50s ago
      Process: 24397 ExecStartPost=/bin/sleep 0.1 (code=exited, status=0/SUCCESS)
      Process: 24393 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
      Process: 24390 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
      Process: 24389 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
     Main PID: 24396 (nginx)
       CGroup: /system.slice/nginx.service
               ├─24396 nginx: master process /usr/sbin/nginx
               └─24398 nginx: worker process
    
    Jun 27 16:50:21 yumsources systemd[1]: Starting The nginx HTTP and reverse proxy server...
    Jun 27 16:50:21 yumsources nginx[24390]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    Jun 27 16:50:21 yumsources nginx[24390]: nginx: configuration file /etc/nginx/nginx.conf test is successful
    Jun 27 16:50:21 yumsources systemd[1]: Started The nginx HTTP and reverse proxy server.
    
    
  • 相关阅读:
    scp常用操作指令
    php 5.6.36 安装mcrypt
    记https在Android浏览器无法访问
    centos 7 源码包安装、卸载nginx
    Linux进程守护——Supervisor 使用记录
    Nginx日志切割工具——logrotate 使用记录
    计算机相关网段计算
    PHP链接sqlserver出现中文乱码
    Yii2 init 与 beforeAction 区别
    利用yii2分页插件,成对取出数组数据
  • 原文地址:https://www.cnblogs.com/leaderjs/p/13198856.html
Copyright © 2011-2022 走看看