服务器自动部署Let's-Encrypt证书教程
安装Cerbot客户端
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Ubuntu/Debian
sudo apt update
sudo apt install certbot
# CentOS/RHEL
sudo yum install epel-release
sudo yum install certbot
#=====================================#
# 如果使用 Nginx/Apache 插件(可选):
# Ubuntu/Debian:
sudo apt install python3-certbot-nginx 或 python3-certbot-apache
# CentOS/RHEL:
sudo yum install certbot-nginx 或 certbot-apache
操作命令及安装过程
- 安装通配符 首次生成证书,在中文注释的地方,需要手动确认
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
> certbot certonly --manual --preferred-challenges=dns -d *.fscloude.cn
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator manual, Installer None
Enter email address (used for urgent renewal and security notices)
(Enter 'c' to cancel): fsbook@fscloude.cn
Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.5-February-24-2025.pdf. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y # (注意: 手动 Y 确认)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: n # (注意: 手动 y/n,是否同意让邮件接收新闻或广告)
Account registered.
Requesting a certificate for *.fscloude.cn
Performing the following challenges:
dns-01 challenge for fscloude.cn
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name
_acme-challenge.fscloude.cn with the following value:
0r0ef0xxxxIxxxxxTxxxxjhWv4EZRxxxxxQZs # (注意: 配置域名解析的TXT值)
Before continuing, verify the record is deployed.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Press Enter to Continue
Waiting for verification...
Cleaning up challenges
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/fscloude.cn/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/fscloude.cn/privkey.pem
Your certificate will expire on 2024-07-02. To obtain a new or
tweaked version of this certificate in the future, simply run
certbot again. To non-interactively renew *all* of your
certificates, run "certbot renew"
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
更新证书
手动更新-通配符不能直接更新
1
2
3
4
5
6
7
8
9
10
11
# 使用此方式更新
certbot certonly --manual --preferred-challenges=dns -d *.fscloude.cn
# 更新时,重新执行此命令
1. certbot certonly --manual --preferred-challenges=dns -d *.fscloude.cn
2. 再 根据生成的 dns 解析 txt,手动加载 域名dns解析中
3. 回到命令行,回车确认以配置
4. nginx reload 配置
自动更新
本文由作者按照
CC BY 4.0
进行授权