我来帮你了解 Certbot 证书续期的相关操作。
1. 手动续期命令
```bash
sudo certbot renew
```
2. 测试续期(不实际续期)
```bash
sudo certbot renew --dry-run
```
3. 自动续期设置
Certbot 通常会自动创建一个 cron 任务或 systemd timer 来处理自动续期:
查看定时任务:
```bash
systemctl list-timers | grep certbot
# 或
crontab -l | grep certbot
```
4. 常见续期配置位置
- /etc/letsencrypt/renewal/
- /etc/cron.d/certbot
- /etc/systemd/system/certbot.timer
5. 注意事项:
- 证书有效期为90天
- Certbot 会在到期前30天自动尝试续期
- 确保80/443端口可访问
- 续期后需要重启 Web 服务器
```bash
sudo systemctl restart nginx # 如果使用 nginx
# 或
sudo systemctl restart apache2 # 如果使用 apache
```
6. 常见问题排查:
```bash
# 查看证书状态
certbot certificates
# 查看详细日志
sudo certbot renew --verbose
# 强制续期
sudo certbot renew --force-renewal
```
7. 最佳实践:
- 定期检查自动续期是否正常工作
- 设置证书续期通知
- 保持服务器时间准确
- 确保 DNS 记录正确
如果遇到续期问题,可以查看 /var/log/letsencrypt/letsencrypt.log 获取详细错误信息。