一、安装
- 检查证书有效期
curl -vvI https://www.xxx.top - 安装certbot
apt install certbot - 安装证书
certbot certonly --webroot --email xxx@gmail.com -w /home/wwwroot/xxx -d www.xxx.top
二、 续期
ssl手动续期
certbot的证书有效期为90天,手动续期
certbot renew
手动续期需要注意两点:
1.80端口没有被占用,因为更新证书需要用到80端口。
2.在到期前30天之内才能续期,否则certbot会判断没有必要进行续期。
自动续期:
vi /sh/renew_ssl.sh
#!/bin/bash
nginx -s quit
certbot renew --force-renewal --renew-hook "nginx" > /sh/ssl_update.log 2>&1 &
–force-renewal:强制更新证书,无视30天之内限制
–renew-hook:证书更新完毕后,将关闭的nginx启动。(没有加入系统路径的要带上路径,如:/usr/local/nginx/sbin/nginx)
脚本执行会有一段时间延迟:
编辑/etc/crontab文件,在文末添加命令,每个月1号,执行一次更新脚本:
0 0 1 * * sh /sh/renew_ssl.sh > /dev/null 2>&1 &
本文详细介绍了如何使用Certbot安装和续期SSL证书,包括使用webroot方法安装证书,手动和自动续期的步骤,以及设置自动续期脚本并通过crontab定时执行。在续期过程中需注意80端口的可用性和证书更新的时间限制。
9647

被折叠的 条评论
为什么被折叠?



