Let’s Encrypt 免费申请泛域名 SSL 证书,并实现自动续期
-
更新
1 | 25-04-07 初始记录 |
环境准备
-
一台可以访问互联网的服务器(Linux 环境,如 Ubuntu/CentOS)。
-
Root 权限或
sudo
权限。 -
一个已解析的域名(本文以
example.com
为例)。
Certbot 自动安装
-
选择安装环境
-
Install system dependencies
For APT-based distributions (e.g. Debian, Ubuntu …):
SHELL
1 | sudo apt update |
For RPM-based distributions (e.g. Fedora, CentOS …):
SHELL
1 | sudo dnf install python3 augeas-libs |
-
Remove certbot-auto and any Certbot OS packages
-
Set up a Python virtual environment
SHELL
1 | sudo python3 -m venv /opt/certbot/ |
-
Install Certbot
SHELL
1 | sudo /opt/certbot/bin/pip install certbot certbot-nginx |
-
Prepare the Certbot command
SHELL
1 | sudo ln -s /opt/certbot/bin/certbot /usr/bin/certbot |
申请单域名 SSL 证书
-
Choose how you’d like to run Certbot
SHELL
1 | sudo certbot --nginx |
这里获取 nginx 默认的配置位置在 /etc/nginx。可以为自己安装完成的 nginx 创建软链到此目录下
-
sudo certbot certonly --nginx
SHELL
1 | echo "0 0,12 * * * root /opt/certbot/bin/python -c 'import random; import time; time.sleep(random.random() * 3600)' && sudo certbot renew -q" | sudo tee -a /etc/crontab > /dev/null |
-
Confirm that Certbot worked
评论
评论插件加载失败
正在加载评论插件