1 安装nginx

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
yum install yum-utils -y

cat > /etc/yum.repos.d/nginx.repo<<EOF
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/8/\$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/8/\$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
EOF

yum-config-manager --enable nginx-mainline
yum install nginx -y
cd /etc/nginx/conf.d/
cp default.conf default.conf.bak
systemctl enable --now nginx
systemctl status nginx

2 安装snap

1
2
3
4
5
dnf install epel-release -y
yum install snapd -y
systemctl enable --now snapd.socket
ln -s /var/lib/snapd/snap /snap
reboot

3 安装certbot

1
2
3
4
5
snap install core
snap refresh core
yum remove certbot -y
snap install --classic certbot
ln -s /snap/bin/certbot /usr/bin/certbot

4 创建证书

1
2
certbot --nginx
cat /etc/nginx/conf.d/default.conf