使用 Certbot 自動申請
-
安裝 Certbot
Certbot 是 Let’s Encrypt 官方推薦的自動化工具,支持多種操作系統和服務器環境。- 在 Ubuntu/Debian 上:
sudo apt update
sudo apt install certbot
- 申請證書
- 純手動方式(不自動配置):
sudo certbot certonly --standalone -d yourdomain.com -d www.yourdomain.com
- 自動續期
Let’s Encrypt 證書有效期為90天,Certbot 默認會安裝自動續期的定時任務,你可以手動測試續期:
sudo certbot renew --dry-run
你已經使用 Certbot 生成了 SSL 證書,默認情況下,證書和密鑰文件會存放在服務器上的以下目錄:
/etc/letsencrypt/live/你的域名/
這個目錄下通常包含以下幾個文件:
fullchain.pem
— 證書鏈(包括你的證書和中間證書)
privkey.pem
— 私鑰
cert.pem
— 你的域名證書
chain.pem
— 中間證書
一般我們使用的是
privkey.pem
— 私鑰cert.pem
— 你的域名證書