在 Debian 上,Nginx 的 SSL 证书最常见是用 Let’s Encrypt(certbot)签发的,续期方式如下。如果你用的是其他证书(商业证书),方式会不同,我也会简单说明。
which certbot
或
certbot --version
如果没有:
sudo apt update
sudo apt install certbot python3-certbot-nginx
sudo certbot renew --dry-run
sudo certbot renew
certbot 只在证书剩余 < 30 天时才会真正更新
Debian 下 certbot 会自动创建:
certbot.timer/etc/cron.d/certbot查看状态:
systemctl status certbot.timer
启用(如果没开):
sudo systemctl enable --now certbot.timer
certbot 默认会:
如果你想手动确认:
sudo nginx -t
sudo systemctl reload nginx
/etc/letsencrypt/live/域名/
├── fullchain.pem
└── privkey.pem
Nginx 配置通常类似:
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
sudo nginx -t
sudo systemctl reload nginx
⚠️ 商业证书不会自动续期,需要你手动操作或写脚本。
Let’s Encrypt 需要验证:
sudo netstat -tlnp | grep ':80'
sudo journalctl -u certbot.timer
sudo certbot certificates
如果你愿意,可以告诉我:
cat /etc/os-release)我可以帮你精确检查。