安装Certbot工具

Ubuntu / Debian 系统

sudo apt-get update
sudo apt-get install certbot

CentOS / RHEL 系统

如果提示 No package certbot available,请先安装 EPEL 源:

sudo yum install epel-release
sudo yum install certbot

常见错误处理

如果使用 certbot 时出现 urllib3 相关错误,尝试升级依赖:

pip install --upgrade requests-toolbelt

💡 提示
如果你是通过系统包管理器安装的 Certbot,且没有安装 pip,可能需要先安装 Python pip。


申请证书

单域名申请

certbot certonly --email YOUR_EMAIL@example.com --standalone -d yourdomain.com

参数说明:

  • --standalone:使用 Certbot 内置的临时 HTTP 服务器验证域名所有权。
  • -d:指定需要申请证书的域名。
  • --email:用于接收安全通知及续期提醒,建议填写真实邮箱。

多域名申请

certbot certonly --email YOUR_EMAIL@example.com --standalone -d yourdomain.com -d www.yourdomain.com

💡 提示
多个 -d 参数可以绑定多个子域名到同一个证书,方便统一管理。


证书存放位置

默认证书路径:

/etc/letsencrypt/live/yourdomain.com/
├── cert.pem        # 证书文件
├── chain.pem       # 证书链
├── fullchain.pem   # 证书 + 证书链
└── privkey.pem     # 私钥文件

注意: 请妥善保护 privkey.pem 私钥文件,避免泄露。


作者:admin  创建时间:2026-02-25 11:29
最后编辑:admin  更新时间:2026-02-26 10:12