首先 因为使用的CentOS 所以默认使用yum安装
- 安装snap
确认自己使用的CentOS版本cat /etc/centos-release
如果使用的是CentOS8如果使用的CentOS71
2sudo dnf install epel-release
sudo dnf upgradesudo yum install epel-release
sudo yum install snapd
如果出现1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16Error: Package: snapd-selinux-2.47.1-1.el7.noarch (epel)
Requires: selinux-policy-base >= 3.13.1-268.el7
Installed: selinux-policy-targeted-3.13.1-266.el7_8.1.noarch (@updates)
selinux-policy-base = 3.13.1-266.el7_8.1
Available: selinux-policy-minimum-3.13.1-266.el7.noarch (base)
selinux-policy-base = 3.13.1-266.el7
Available: selinux-policy-minimum-3.13.1-266.el7_8.1.noarch (updates)
selinux-policy-base = 3.13.1-266.el7_8.1
Available: selinux-policy-mls-3.13.1-266.el7.noarch (base)
selinux-policy-base = 3.13.1-266.el7
Available: selinux-policy-mls-3.13.1-266.el7_8.1.noarch (updates)
selinux-policy-base = 3.13.1-266.el7_8.1
Available: selinux-policy-targeted-3.13.1-266.el7.noarch (base)
selinux-policy-base = 3.13.1-266.el7
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigestyumdownloader snapd-selinux-2.47.1-1.el7.noarch
rpm –force –nodeps -ivh
启动并且开启端口sudo systemctl enable --now snapd.socket
为了支持旧模式,建立一个链接sudo ln -s /var/lib/snapd/snap /snap
2. 安装CertBotsudo snap install --classic certbot
为CertBot创建一个软链接sudo ln -s /snap/bin/certbot /usr/bin/certbot
如果想要覆盖nginx配置
sudo certbot –nginx
如果不想覆盖nginx配置
sudo certbot certonly –nginx
测试自动更新证书功能
sudo certbot renew –dry-run
可以验证域名了