Let’s Encrypt 免费申请泛域名 SSL 证书,并实现自动续期
Kiml Lv5
1
25-04-07 初始记录

环境准备

  • 一台可以访问互联网的服务器(Linux 环境,如 Ubuntu/CentOS)。

  • Root 权限或 sudo 权限。

  • 一个已解析的域名(本文以 example.com 为例)。

Certbot 自动安装

  1. 选择安装环境
    image

  2. Install system dependencies
    For APT-based distributions (e.g. Debian, Ubuntu …):

SHELL
1
2
sudo apt update
sudo apt install python3 python3-venv libaugeas0

For RPM-based distributions (e.g. Fedora, CentOS …):

SHELL
1
sudo dnf install python3 augeas-libs
  1. Remove certbot-auto and any Certbot OS packages

  2. Set up a Python virtual environment

SHELL
1
2
sudo python3 -m venv /opt/certbot/
sudo /opt/certbot/bin/pip install --upgrade pip
  1. Install Certbot

SHELL
1
sudo /opt/certbot/bin/pip install certbot certbot-nginx
  1. Prepare the Certbot command

SHELL
1
sudo ln -s /opt/certbot/bin/certbot /usr/bin/certbot

申请单域名 SSL 证书

  1. Choose how you’d like to run Certbot

SHELL
1
2
3
4
sudo certbot --nginx

# 手动配置 nginx
sudo certbot certonly --nginx

这里获取 nginx 默认的配置位置在 /etc/nginx。可以为自己安装完成的 nginx 创建软链到此目录下

  1. 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
  1. Confirm that Certbot worked

 评论
评论插件加载失败
正在加载评论插件
由 Hexo 驱动 & 主题 Keep v4.2.5
访客数 634 访问量 2664