nginx Failed to read PID from file /run/nginx.pid: Invalid argument - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
tmackan
V2EX    NGINX

nginx Failed to read PID from file /run/nginx.pid: Invalid argument

  •  
  •   tmackan
    tmacjx 2016-08-22 16:32:15 +08:00 8699 次点击
    这是一个创建于 3337 天前的主题,其中的信息可能已经有所发展或是发生改变。

    启动 nginx 后查看 status 显示

    Redirecting to /bin/systemctl status nginx.service ● nginx.service - The nginx HTTP and reverse proxy server Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled) Active: active (running) since 一 2016-08-22 16:19:58 CST; 2min 51s ago Main PID: 13423 (nginx) CGroup: /system.slice/nginx.service ├─13423 nginx: master process /usr/sbin/nginx └─13424 nginx: worker process

    8 月 22 16:19:58 iZ230ph83b2Z systemd[1]: Starting The nginx HTTP and reverse proxy server... 8 月 22 16:19:58 iZ230ph83b2Z nginx[13417]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok 8 月 22 16:19:58 iZ230ph83b2Z nginx[13417]: nginx: configuration file /etc/nginx/nginx.conf test is successful 8 月 22 16:19:58 iZ230ph83b2Z systemd[1]: Failed to read PID from file /run/nginx.pid: Invalid argument 8 月 22 16:19:58 iZ230ph83b2Z systemd[1]: Started The nginx HTTP and reverse proxy server. 8 月 22 16:22:39 iZ230ph83b2Z systemd[1]: Started The nginx HTTP and reverse proxy server.

    Failed to read PID from file /run/nginx.pid: Invalid argument 这是为何, google 半天没解决,求大神指点。

    12 条回复    2016-08-26 13:14:36 +08:00
    tmackan
        1
    tmackan  
    OP
       2016-08-22 16:32:43 +08:00
    坐等大神
    lostsquirrel
        2
    lostsquirrel  
       2016-08-22 16:57:51 +08:00
    你确定你有`/run` 这个目录
    tmackan
        3
    tmackan  
    OP
       2016-08-22 17:08:21 +08:00
    @lostsquirrel
    这个文件的确存在
    文件内容是
    13423
    ss098
        4
    ss098  
       2016-08-22 17:13:35 +08:00 via Android
    @tmackan /run 应该是一个目录而不是文件,你备份一下这个文件然后创建 /run 目录。
    lostsquirrel
        5
    lostsquirrel  
       2016-08-22 17:26:27 +08:00
    把 nginx.pid 这个文件删除了再启动
    lhbc
        6
    lhbc  
       2016-08-22 17:29:20 +08:00   4
    因为 nginx 启动需要一点点时间,而 systemd 在 nginx 完成启动前就去读取 pid file
    造成读取 pid 失败

    解决方法很简单,让 systemd 在执行 ExecStart 的指令后等待一点点时间即可
    如果你的 nginx 启动需要时间更长,可以把 sleep 时间改长一点

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

    然后
    systemctl daemon-reload
    systemctl restart nginx.service
    tmackan
        7
    tmackan  
    OP
       2016-08-22 18:02:41 +08:00
    @lhbc 你好, nginx 正常启动了
    我用 uwsgi 开启了一个服务,分配了对应的端口号,防火墙也已经关闭,但是通过 IP 还是访问不了
    可能是什么原因呢?
    tmackan
        8
    tmackan  
    OP
       2016-08-22 18:06:21 +08:00
    @lhbc 显示拒绝了连接请求
    lhbc
        9
    lhbc  
       2016-08-22 18:13:39 +08:00
    @tmackan 指定了 server_name 的话,用 IP 可能无法访问
    curl -I -H "host: <DOMAIN>" <IP>
    替换 <> 里面的为你自己的域名和 IP ,测试看
    tmackan
        10
    tmackan  
    OP
       2016-08-22 18:28:21 +08:00
    @lhbc server_name 填写的是 ip 地址
    tmackan
        11
    tmackan  
    OP
       2016-08-22 18:29:08 +08:00
    @lhbc 还没有申请域名
    填写的是 ip:端口号
    tmackan
        12
    tmackan  
    OP
       2016-08-26 13:14:36 +08:00
    @lhbc 哥们你好,还得麻烦你有遇到这个问题吗?
    http://www.v2ex.com/t/301307#reply2
    感谢
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2512 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 32ms UTC 01:55 PVG 09:55 LAX 18:55 JFK 21:55
    Do have faith in what you're doing.
    ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86