1.安装Certbot
sudo apt install certbot python3-certbot-nginx
2.生成证书
certbot --nginx
然后输入邮箱,选择要生成的域名,选择是否要重定向,
SSL证书具体位置:/ect/letsencrypt/live
下
通过上面两步,直接将Nginx配置写入了已存在的配置文件
证书美国三个月会过期,但是可以无限续签,可通过以上命令重新申请,也可重新需续签或者自动续签
certbot renew --force-renew
自动续签
crontab -e
0 3 1 * * certbot renew --force-renew