在 Debian 上,Nginx 的 SSL 证书续期方式取决于你用什么方式申请的证书。最常见的是 Let’s Encrypt(certbot)。下面分情况说明。
which certbot
如果没有:
sudo apt update
sudo apt install certbot python3-certbot-nginx
sudo certbot renew --dry-run
sudo certbot renew
certbot 会:
Debian 通常已自动配置:
systemctl list-timers | grep certbot
或:
cat /etc/cron.d/certbot
一般会有:
0 */12 * * * root certbot renew -q
手动重载:
sudo nginx -t
sudo systemctl reload nginx
certbot 不适用,需要手动更换:
/etc/ssl/certs/xxx.crt
/etc/ssl/private/xxx.key
ssl_certificate /etc/ssl/certs/xxx.crt;
ssl_certificate_key /etc/ssl/private/xxx.key;
sudo nginx -t
sudo systemctl reload nginx
sudo certbot certificates
certbot 默认用 HTTP-01 验证,需要 80 端口可达。
sudo certbot certonly --manual --preferred-challenges dns
✅ certbot + nginx 插件
✅ 自动续期
✅ 监控证书剩余天数
如果你愿意,可以告诉我:
我可以给你精确命令。