已完成内容
[x] 安装
[x] 更新
前言
在之前的博客中也写过一次Certbot 的安装,但是这两天发现 Certbot 他居然更新教程了。所以为了我自己以后方便使用,也重新出一次教程吧。内容也基本照搬 Certbot 的官网。
环境
- 我用的还是用的是 LNMP 1.6 (可以尝试使用 1.7,只是我习惯1.6了)
- Linux 环境用的是 Centos7.x
安装
安装 snapd
可以去官网查看教程, 也可以跟着下面的命令跟着敲。
sudo yum install epel-release snapd -y
sudo systemctl enable --now snapd.socket
sudo ln -s /var/lib/snapd/snap /snap
上面不懂的可以去snapd的官网去了解一下,这边不多做解释了。
删除原来版本的 Certbot
如果是第一次装 Certbot 跳过这一步
sudo apt-get remove certbot
sudo dnf remove certbot
sudo yum remove certbot.
通过 snapd 安装 Certbot
sudo snap install --classic certbot
添加软连
sudo ln -s /snap/bin/certbot /usr/bin/certbot
添加 SSL 证书
这里官网这边直接使用
sudo certbot --nginx
或者
sudo certbot certonly --nginx
你会发现没办法正常生成 SSL,这是因为我这边使用的是 LNMP 安装的 NGINX,所以在 使用 Certbot 的时候需要指定 NGINX 目录
sudo certbot --nginx --nginx-server-root=/usr/local/nginx/conf
这样安装就可以自行安装了。
更新
官方说明 使用 snapd 安装的 Certbot 会自行更新 SSL 原文如下:
The Certbot packages on your system come with a cron job or systemd timer that will renew your certificates automatically before they expire. You will not need to run Certbot again, unless you change your configuration.
如果需要手动更新 SSL 证书的话 执行这个就可以了~
sudo certbot renew --dry-run
然后就可以 访问你的网站看 你的 SSL 证书有没有正常使用就好啦~