使用 certbot-auto
这是官方推荐的方法,通过 shell 命令的方式,可以最简单方便地达到目的。步骤如下:
- 访问 certbot 网站,地址为:https://certbot.eff.org/
- 在首页选择好 webserver 和 系统类型,则会显示对应的操作步骤。按照步骤逐步操作,如无意外则可完成。
- 修改 webserver 服务配置支持 https。nginx 可以参考: https://lzw.me/a/http2-nginx.html
注意:如服务器已启用了 https 服务,则先停止它。certbot-auto 在作验证时会使用 433 端口。
centos6 下 nginx 使用 certbot-auto
以 Centos 下的 nginx 为例,主要步骤如下。
1 下载 certbot-auto
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
2 执行自动安装
./certbot-auto --nginx
该命令会尝试自动配置 nginx 。
你也可以只生成适合 nginx 使用的证书,然后手动配置 nginx:
certbot-auto --nginx certonly
生成成功后,可以查看证书状态:
./certbot-auto certificates
nginx 配置请参考: https://lzw.me/a/http2-nginx.html
3 更新证书
自动生成的证书有效期为 90 天。在到期前应当更新证书。方法参考如下:
测试自动更新:
./certbot-auto renew --dry-run
执行自动更新:
service nginx stop
certbot-auto renew
service nginx start
更新成功后,查看证书状态:
./certbot-auto certificates
详细参考:https://certbot.eff.org/#centos6-nginx
使用第三方脚本
使用 dehydrated,参考:
http://www.ituring.com.cn/article/211255
https://github.com/lukas2511/dehydrated
相关链接
https://letsencrypt.org/getting-started/
https://github.com/letsencrypt/letsencrypt