Let's Encrypt SSL
!/bin/bash
安装 certbot(如果你还没有安装)
sudo apt-get update
sudo apt-get install certbot python3-certbot-nginx -y # 对于基于 Debian/Ubuntu 的系统且使用 Nginx
或者对于 CentOS/RHEL 系统:
sudo yum install epel-release -y
sudo yum install certbot python3-certbot-nginx -y # 如果使用 Nginx
对于仅获取证书,不依赖特定 web 服务器插件:
sudo yum install certbot python3-certbot -y
申请证书
--agree-tos 表示同意 Let's Encrypt 的服务条款
-d 指定你的域名
--email 提供用于接收重要更新和续期通知的邮箱地址
sudo certbot certonly --agree-tos -m your@email.com -d example.com -d www.example.com
配置自动续期(Certbot 默认已经设置好了自动续期任务)
可以检查或手动运行以确保证书及时续期
sudo certbot renew --dry-run # 进行一次模拟续期操作来测试配置是否正确