Certbot申请ssl证书

先DNS解析

环境安装

安装epel
yum install epel-release

安装snapd
yum install snapd

启用snapd.socket
systemctl enable --now snapd.socket

创建/var/lib/snapd/snap和/snap之间的链接
ln -s /var/lib/snapd/snap /snap

在~/.bashrc添加如下代码
export PATH=$PATH:~/.jx/bin:/snap/bin

然后再执行
source ~/.bashrc

将snap更新至最新版本
snap install core
snap refresh core

安装certbot

通过snap安装certbot
snap install --classic certbot

创建/snap/bin/certbot的软链接,方便certbot命令的使用。
ln -s /snap/bin/certbot /usr/bin/certbot

申请泛域名证书

certbot certonly --manual \
--preferred-challenges=dns \
--email mail@qq.com \
--server https://acme-v02.api.letsencrypt.org/directory \
--agree-tos \
--manual-public-ip-logging-ok \
-d "*.domain.com" -d "domain.com"

会提下如下信息

Please deploy a DNS TXT record under the name:

_acme-challenge.xxxx.com.

with the following value:

u98pP5WLXFbx7nM8AdG4JnGiGicKamKlmxRqJUpPNpw

DNS解析,添加一条TXT记录,记录名是_acme-challenge,然后记录值,这里是u98pP5WLXFbx7nM8AdG4JnGiGicKamKlmxRqJUpPNpw

回车,生成证书,一般位置是在/etc/letsencrypt/live/xxxx.com/这个目录下

更新证书

更新证书
certbot renew

自动续期
crontab -e 
0 0 1 * * /usr/bin/certbot renew --force-renewal

apache服务器

/etc/init.d/apache2 start
/etc/init.d/apache2 stop
/etc/init.d/apache2 status