前往certbot官网,https://certbot.eff.org/,选择自己的服务器信息,获取安装命令。
1 sudo apt-get update
1.1 sudo apt-get install software-properties-common
1.2 sudo add-apt-repository universe
1.3 sudo add-apt-repository ppa:certbot/certbot
1.4 sudo apt-get update
2 sudo apt-get install certbot python-certbot-nginx
3 sudo certbot --nginx 根据提示选择配置
完成后会在对应的nginx网站配置下生成证书。
加密证书只有90天有效。这是为了鼓励用户自动执行证书续订过程。certbot我们安装的软件包通过systemd计时器每天运行两次“certbot renew”来为我们解决这个问题。在非系统发行版上,此功能由放置在其中的脚本提供/etc/cron.d。此任务每天运行两次,并将续订任何在到期后30天内的证书。
要测试更新过程,您可以执行以下操作certbot:
sudo certbot renew --dry-run
如果您没有看到任何错误,那么您已经完成了设置。必要时,Certbot将续订您的证书并重新加载Nginx以获取更改。如果自动续订过程失败,我们的加密将向您指定的电子邮件发送一条消息,并在您的证书即将过期时发出警告。