在 CentOS 上使用 Nginx 和 Certbot 自动续期 Let’s Encrypt SSL 证书的详细流程,2025年最新简便流程。

  1. 安装 Certbot

    sudo yum install epel-release
    sudo yum install certbot python2-certbot-nginx
  2. 生成证书

    sudo certbot certonly --webroot -w /www/wwwroot/xigk.com -d xigk.com -d www.xigk.com

    这里 -w /www/wwwroot/xigk.com 指定网站的根目录路径,确保 Let’s Encrypt 可以访问 .well-known/acme-challenge 文件夹以验证域名所有权。
    按提示下一步,然后会生成证书的目录

    /etc/letsencrypt/live/xigk.com/fullchain.pem
    /etc/letsencrypt/live/xigk.com/privkey.pem

    去更新 Nginx 配置文件,配置最新的SSL路径上去。

  3. 添加,每周定时shell任务
    任务类型:shell脚本
    脚本内容:certbot renew
    成功搞定SSL证书的申请和自动续期啦!
  4. 注意,证书续期频率限制:Let's Encrypt 对证书续期有频率限制(每周最多 5 次),因此不要频繁运行 certbot renew。
    Let's Encrypt 证书的有效期为 90 天,certbot renew 只会在证书到期前 30 天内尝试续期。所以每周一次请求就行了。

标签: none

添加新评论