Skip to content

Commit 45005a7

Browse files
committed
Add: 添加文章
1 parent 5253828 commit 45005a7

File tree

2 files changed

+111
-0
lines changed

2 files changed

+111
-0
lines changed

.vitepress/sidebar/newTools.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ const newToolsSidebar: SidebarType[] = [
66
link: '/new-tools/',
77
readonly: true,
88
items: [
9+
{
10+
text: '使用 Certbot 生成泛域名 SSL 证书',
11+
link: '/new-tools/use_certbot_generate_generic_domain_name_ssl_cert'
12+
},
913
{
1014
text: 'artalk 评论系统安装与配置教程(docker版)',
1115
link: '/new-tools/docker_install_artalk'
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
lastUpdated: 2025/08/07 09:43
3+
---
4+
5+
# 使用 Certbot 生成泛域名 SSL 证书
6+
7+
## 为什么要用 Certbot 注册,而不是用国内云服务器厂商申请的证书
8+
9+
因为我已经受够了国内这些云服务器厂商无耻的骚操作了!!!
10+
11+
就拿华为云为例:
12+
13+
1. 非免费证书售价高得离谱!一个正常的SSL证书居然2000块钱起步!
14+
2. 免费证书是有,也是三个月时效(👉谷歌缺大德),但是只能申请20次!(不是哥们,免费证书你也限制次数!)
15+
3. 第三点是最重要的,居然不能申请泛域名证书!这意味着,你有一个主域名和三个子域名,那么你得申请4个免费测试证书!(逆天)
16+
17+
所以,certbot 这时候的重要性就突出来了:他免费,快速,而且能申请泛域名,这代表你一个证书就能完成一个域名的所有使命了!(真香)
18+
19+
## 如何使用 Certbot 注册证书
20+
21+
很简单!你只需要很轻松的几个步骤就能搞定!
22+
23+
### 安装 Certbot
24+
25+
首先你得安装 Certbot,使用以下命令:
26+
27+
- Ubuntu / Debian:
28+
29+
```sheel
30+
sudo apt update
31+
sudo apt install certbot python3-certbot-nginx
32+
```
33+
34+
- CentOS / RHEL:
35+
36+
```sheel
37+
sudo apt update
38+
sudo apt install certbot python3-certbot-nginx
39+
```
40+
41+
- macOS(通过 Homebrew):
42+
43+
```sheel
44+
sudo apt update
45+
sudo apt install certbot python3-certbot-nginx
46+
```
47+
48+
### 申请证书
49+
50+
是的,安装完成后,你就可以直接申请证书了
51+
52+
因为我没有用自动续签,这里我只示范如何手动申请流程:
53+
54+
#### 执行申请命令
55+
56+
使用以下命令:
57+
58+
```shell
59+
sudo certbot certonly --manual --preferred-challenges dns -d "*.example.com" -d example.com
60+
```
61+
62+
> `example.com` 替换成你的域名地址
63+
64+
#### 设置邮箱
65+
66+
如果是第一次,它可能需要你提供一个邮箱地址,你只需要输入正确的邮箱地址即可
67+
68+
#### 添加 DNS 解析
69+
70+
接着,它会提示你,需要去域名DNS解析里添加一条名为 `_acme-challenge.example.com` (注意替换称自己的域名) 的 TXT 记录
71+
72+
这条记录仅用于鉴定你对该域名是否具有所有权
73+
74+
它会给你一串随机字符码,你只需要将该值填入 `_acme-challenge.example.com` 记录中即可
75+
76+
添加后稍等生效,然后继续 Certbot 流程
77+
78+
::: tip 注意
79+
有可能会有两次提示你添加随机字符码到该记录里,你只需要重新删除记录里的值,重新设置即可
80+
:::
81+
82+
#### 生成证书
83+
84+
到目前,所有步骤已走完,只需等待它返回证书文件
85+
86+
一般它会将生成的证书放置到 `/etc/letsencrypt/live/example.com/` 目录下:
87+
88+
- 证书本体:fullchain.pem
89+
- 证书密钥:privkey.pem
90+
91+
### 配置证书
92+
93+
以 nginx 为例:
94+
95+
```nim
96+
server {
97+
listen 443 ssl;
98+
server_name namichong.com *.namichong.com;
99+
100+
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
101+
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
102+
103+
...
104+
}
105+
```
106+
107+
然后,使用 `nginx -s reload` 重启即可

0 commit comments

Comments
 (0)