Ubuntu20.04通过Certbot安装ssl证书
1.安装Certbot
sudo apt install certbot python3-certbot-nginx
2.生成证书
sudo certbot --nginx
然后输入邮箱,选择要生成的域名,选择是否要重定向,
SSL证书具体位置:/ect/letsencrypt/live
下
通过上面两步,直接将Nginx配置写入了已存在的配置文件
证书美国三个月会过期,但是可以无限续签,可通过以上命令重新申请,也可重新需续签或者自动续签
sudo certbot renew --force-renew
自动续签
crontab -e
0 3 1 * * sudo certbot renew --force-renew
自动续签
certbot的更新证书命令,这个命令会自动判断是否需要更新,如果没有满足条件,会跳过更新。
sudo certbot renew --cert-name xxx.xxx.com --post-hook "sudo systemctl restart nginx && sudo systemctl restart ..."