certbot 安装
apt-get install software-properties-common (已安装请忽略此步骤)
add-apt-repository ppa:certbot/certbot
apt-get update
apt-get -y install python-certbot-nginx (ubuntu 16 版本)
apt-get -y install python3-certbot-nginx (ubuntu 20 版本)
1. apt install certbot
2. apt-get -y install python3-certbot-nginx (ubuntu 22.04 版本)
certbot 配合nginx部署https
前提 :nginx已经配置了域名
方式1: certbot --nginx (当linux有多个版本nginx,会出现找错nginx的配置文件路径)
方式2: certbot --nginx-server-boot /usr/local/nginx/conf (指定nginx的配置文件路径)
certbot 常用命令:
certbot certificates
就可以看到当前机器所有域名的证书情况,包括域名、 到期日、证书路径、私钥路径四条信息。
续费所有的域名
certbot renew
删除过期不用的域名
certbot delete --cert-name example.com
每日定时任务检查证书并更新
crontab -e
0 0 1 * * /usr/bin/certbot renew --force-renewal