在ubuntu等linux系统上申请https证书
使用 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
— 你的域名证书