温馨提示×

nginxssl在debian上如何续期

小樊
40
2026-09-11 14:49:56
栏目: 云计算

在 Debian 上,如果你是用 Let’s Encrypt + Certbot 申请的 SSL 证书(最常见情况),续期非常简单。下面分情况说明。


一、使用 Certbot(最常见)

1. 测试续期(不会真正更新)

sudo certbot renew --dry-run

2. 手动立即续期

sudo certbot renew

3. 自动续期(推荐)

Certbot 安装后会自动添加 systemd timer 或 cron:

  • 查看 timer 是否启用:
systemctl status certbot.timer
  • 若未启用:
sudo systemctl enable --now certbot.timer

Certbot 默认会在证书 剩余 < 30 天 时自动续期。


二、Nginx 重新加载证书

续期后需要让 Nginx 重新加载:

sudo nginx -t
sudo systemctl reload nginx

Certbot 一般会自动执行 reload,但手动确认更稳妥。


三、如果你用的是 snap 安装的 certbot

Debian 12+ 推荐 snap 安装:

sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot

续期命令一样:

sudo certbot renew

四、如果你用的是 acme.sh

acme.sh --renew -d example.com

或自动续期(默认已配置 cron):

acme.sh --cron

Nginx 需手动 reload:

systemctl reload nginx

五、检查证书有效期

echo | openssl s_client -servername example.com -connect example.com:443 2>/dev/null | openssl x509 -noout -dates

如果你能告诉我:

  • Debian 版本
  • 是否使用 Certbot / acme.sh
  • Nginx 配置文件路径

我可以给你更精确的命令。

0