sudo apt update && sudo apt install certbot
安装成功之后需要使用sudo命令运行, 我们运行看看:
sudo certbot -h
获取证书
安装好管理工具之后, 我们需要申请证书下来, 这里我的web服务器是NGINX, 并且我没有网站的静态目录, 所以我使用这个命令申请:
sudo certbot certonly --standalone -d example.com -d www.example.com -d m.example.com
如果你的网站有静态目录的话, 可以把--standalone改成--webroot并且加上-w参数申请, 类似这样:
sudo certbot certonly --webroot -w /var/www/example -d example.com -d www.example.com
在你使用--standalone申请证书的时候需要关闭nginx, 因为certbot会启用443端口校验你的域名信息, 如果nginx没有关闭, 会导致端口占用, 所以我们关闭nginx, 我这里是使用ubuntu, 所以使用这个命令关闭nginx:
sudo services nginx stop
自動更新
Certbot 套件內建自動排程可以在到期之前自動更新憑證。因為 Let’s Encrypt 憑證只有 90 天,所以推薦使用這個功能。您可以利用下面的指令測試自動更新:
1
2
3
4
$ sudo certbot renew --dry-run
檢查自動更新
$ sudo systemctl status certbot.timer
本文由 admin 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为: May 18, 2021 at 11:58 pm