【问题标题】:Certbot renew: nginx: [error] open() "/run/nginx.pid" failed (2: No such file or directory)Certbot renew: nginx: [error] open() "/run/nginx.pid" failed (2: No such file or directory)
【发布时间】:2018-09-09 07:10:13
【问题描述】:

Certbot 和 nginx 版本:

certbot 使用certbot.eff.org 安装指南安装。

  • Certbot 版本:0.22.2
  • Nginx 版本:1.10.3

获取 ssl 证书可以正常工作:

certbot --nginx

但是,在更新cerbot认证时

certbot renew --dry-run

nginx启动失败导致:

nginx: [error] open() "/run/nginx.pid" failed (2: No such file or directory)

我已经尝试在/etc/letsencrypt/renewal/*com.conf/ 中更改 post-hook 和 pre-hook

  • 评论installer=nginx
  • 将身份验证器更改为 nginx 和独立

/etc/letsencrypt/renewal-hooks/pre//etc/lestencrypt/renewal-hooks/post/中添加post和pre hook来停止和启动nginx服务。

似乎 nginx 没有正确启动或没有正确停止。 续订完成后,nginx 失败并显示 (code=exited, status=1/FAILURE)

Nginx 错误日志显示:

certbot 更新时出错:

【问题讨论】:

  • 尝试杀掉挂着的nginxkillall nginx
  • 之前的 nginx stater 是“sudo nginx”吗?
  • 是的,当从 bash shell 启动时,nginx 命令有效。 nginx 仅在 certbot renew --dry-run 上失败。我认为 certbot 在启动之前已读取 nginx.pid 。因为 pre-hook 已经停止了 nginx 服务。
  • @Larry.He 在 certbot pre-hook 中杀死 nginx?
  • 我设法让它工作,将身份验证器设置为 nginx,评论 pre_hook 并将 post_hook 更改为 systemctl start nginx/etc/letsecrypt/renewal/*.com.conf 中的 systemctl restart nginx

标签: nginx certbot renewal


【解决方案1】:

尝试执行:

sudo service nginx restart

然后测试你的 nginx 配置文件(直到你看到“nginx: configuration file /etc/nginx/nginx.conf test is successful”)

sudo nginx -s reload -t

注意证书路径和其他内容

然后重新加载不带-t选项的配置:

sudo nginx -s reload

不建议修改/etc/letsencrypt/ 中的配置文件,但创建(如果不存在) 并在此处修改cli.ini 文件对我有用。您可以在此文件中指定一次post-hook,它将适用于您的所有证书,请参阅我当前的文件:

# /etc/letsencrypt/cli.ini
max-log-backups = 0
authenticator = webroot
webroot-path = /var/www/html
post-hook = service nginx reload
text = True

我希望这将有助于未来的读者。解决方案来源是here(不过文章是俄文的)

【讨论】:

    【解决方案2】:

    我在 Ubuntu 16.04 上遇到了同样的问题

    我刚刚删除了 /etc/letsencrypt/renewal/*.conf 中的 post 和 pre 挂钩,并将验证器更改为 nginx - 我有两个条目 standalone

    它现在工作正常。

    编辑:

    Recommended way 更新续订配置是使用以下方法重新颁发新证书:

    certbot -i nginx -d example.com -d www.example.com certonly

    【讨论】:

    【解决方案3】:

    我有同样的错误......

    当我安装 certbot 时,我按照说明输入了一个 cronjob (5 3 15 * *):

    certbot renew --pre-hook "service nginx stop" --post-hook "service nginx start"
    

    今天早上nginx死了,日志显示

    open() "/run/nginx.pid" failed (2: No such file or directory)
    

    这两者我没有连接,但是我理解是certbot触发了nginx失败吗?

    【讨论】:

      猜你喜欢
      • 2021-06-02
      • 2017-02-08
      • 1970-01-01
      • 2021-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-21
      • 2020-09-03
      相关资源
      最近更新 更多