找不到可用的“nginx”二进制文件。确保 nginx 存在,二进制文件可执行

nic*_*ick 9 ubuntu certificate nginx

我正在尝试在我的数字海洋水滴上安装 certbot。我正在使用 ubuntu 20.04 并按照https://certbot.eff.org/lets-encrypt/ubuntufocal-nginx的说明进行操作。

当我运行时出现错误sudo certbot --nginx。我得到的错误是:

The nginx plugin is not working; there may be problems with your existing configuration.
The error was: NoInstallationError("Could not find a usable 'nginx' binary. 
Ensure nginx exists, the binary is executable, and your PATH is set correctly.")
Run Code Online (Sandbox Code Playgroud)

这是我第一次使用数字海洋等,所以请解释一下解决方案。谢谢。

Lit*_*aya 13

您可以使用选项指定“nginx”二进制文件和conf目录的路径(nginx.conf如果您不手动指定,certbot似乎需要nginx安装目录中的文件)

certbot certonly --nginx --nginx-ctl /usr/local/openresty/nginx/sbin/nginx --nginx-server-root /usr/local/openresty/nginx/conf
Run Code Online (Sandbox Code Playgroud)

  • GCP 上 Debian Buster 上的 Certbot 0.31.0,我必须指定 --nginx-ctl /usr/sbin/nginx (2认同)

adr*_*TNT 11

我在 CentOS 7 上遇到了这个问题,Nginx 可能是从 Epel 安装的。Renew 可以从命令行运行,但不能从 cronjob 运行。我在 LetsEncrypt 日志中发现了这一点:Could not find a usable 'nginx' binary

所以我尝试了 @Jerther 在评论中所说的,指定--nginx-ctl。首先我得到了 nginx 路径:然后我在 crontab 命令中which nginx使用了返回的路径。/usr/sbin/nginx

所以在我的 crontab 中我替换了:

/usr/bin/certbot renew

/usr/bin/certbot --nginx-ctl /usr/sbin/nginx renew