Certbot可以配置为在证书过期之前自动更新证书。由于Let’s Encrypt SSL证书有效期时间为90天,所以建议您利用此功能。您可以通过运行以下命令来测试证书的自动续订:
1
| certbot --nginx certonly
|
我这里直接执行出现一系列错误,处理方法
找不到nginx插件

安装certbot-nginx插件
1
| pip install certbot-nginx
|
找不到nginx

1
| ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
|
找不到nginx配置文件

1
| ln -s /usr/local/nginx/conf/ /etc/nginx
|
再次测试
1
| certbot --nginx certonly
|

如果以上正常工作,你可以通过添加运行以下操作的cron或systemd定时任务安排自动更新
写一个自动执行脚本
添加以下内容
1
| 0 */6 * * * /usr/bin/certbot renew --quiet && /bin/systemctl reload nginx #每6小时执行一次
|
或
1
| 0 0 0,12 * * /usr/bin/certbot renew --quiet && /bin/systemctl reload nginx #每天0点和12点执行
|