我服务器使用nginx,域名需要https,想到使用certbot签发,遇到问题记录一下 1、 yum 按的版本过旧(1.11.0),但是可以使用,但是我选择安装新版本(5.7.0),使用snapd安装,snap 自带所有依赖,不用编译,装完直接能用。 先安装snapd,卸载之前安装的版本 617 yum install -y epel-release 618 yum install -y snapd 619 systemctl enable --now snapd.socket 620 ln -s /var/lib/snapd/snap /snap 621 yum remove -y certbot python3-certbot-nginx 622 snap install --classic certbot error: too early for operation, device not yet seeded or device model not acknowledged snapd 还没完成初始化。等它种子结束后再装: # 1. 重启 snapd 并等待 seed 完成 sudo systemctl restart snapd sudo systemctl restart snapd.seeded # 2. 等待几秒,检查 snap 状态 sleep 5 snap changes --- [root@iZ2vcbzjv501vm9rn17jahZ home]# certbot --nginx Saving debug log to /var/log/letsencrypt/letsencrypt.log 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.") 插件装上了,但 certbot 找不到 nginx 可执行文件。先确认 nginx 位置: [root@iZ2vcbzjv501vm9rn17jahZ home]# which nginx || find / -name nginx -type f 2>/dev/null /usr/bin/which: no nginx in (/opt/jdk17/jdk-17.0.12+7/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin) /usr/local/nginx/sbin/nginx /home/nginx-1.30.2/objs/nginx [root@iZ2vcbzjv501vm9rn17jahZ home]# 位置在 /usr/local/nginx/sbin/nginx,创建软链接就行: ln -sf /usr/local/nginx/conf /etc/nginx [root@iZ2vcbzjv501vm9rn17jahZ home]# certbot --nginx Saving debug log to /var/log/letsencrypt/letsencrypt.log Certbot has detected that nginx version < 1.13.0 or compiled against openssl < 1.0.2l. Since these are deprecated, the configuration file being installed at /etc/letsencrypt/options-ssl-nginx.conf will not receive future updates. To get the latest configuration version, update nginx. Enter email address or hit Enter to skip. (Enter 'c' to cancel): 已经在跑了,只是有个警告——nginx 版本或 openssl 偏旧,SSL 配置文件不会自动更新,但不影响证书签发。 直接输入你的邮箱地址然后回车,后面的步骤: 输入邮箱 → 用于证书到期提醒 同意服务条款 → 输入 A 是否分享邮箱(EFF 推广邮件)→ N 就行 选择域名 → 会列出 nginx 配置里 detect 到的域名,输入序号 之后 certbot 会自动修改 nginx 配置加入 SSL 并重启。一条龙。