虾氲叱
2025-9-28 18:15:44
具体操作流程
第一步:备份现有配置
备份nginx配置
- cp /etc/nginx/conf.d/yunche.conf /etc/nginx/conf.d/yunche.conf.backup.$(date+%Y%m%d)
复制代码 备份现有SSL证书
- cp -r /data/nginx/ssl /data/nginx/ssl.backup.$(date +%Y%m%d)
复制代码 第二步:安装acme.sh- curl https://get.acme.sh | sh -s email=你的邮箱@example.com
- source ~/.bashrc
复制代码 第三步:配置腾讯云DNS API- export Tencent_SecretId="你从腾讯云获取的SecretId"
- export Tencent_SecretKey="你从腾讯云获取的SecretKey"
复制代码 保存到环境变量- echo 'export Tencent_SecretId="你的SecretId"' >> ~/.bashrc
- echo 'export Tencent_SecretKey="你的SecretKey"' >> ~/.bashrc
复制代码 第四步:申请Let's Encrypt证书- # 先测试模式
- ~/.acme.sh/acme.sh --issue --test \
- -d wx.fengyunyunche.com \
- --dns dns_tencent
复制代码- # 测试成功后申请正式证书
- ~/.acme.sh/acme.sh --issue \
- -d wx.fengyunyunche.com \
- --dns dns_tencent
复制代码 第五步:部署证书到你的目录- ~/.acme.sh/acme.sh --install-cert -d wx.fengyunyunche.com \
- --key-file /data/nginx/ssl/wx.fengyunyunche.com.key \
- --fullchain-file /data/nginx/ssl/wx.fengyunyunche.com_bundle.crt \
- --reloadcmd "nginx -t && nginx -s reload"
复制代码 第六步:验证自动续期- # 查看续期任务是否已设置
- crontab -l | grep acme
复制代码- # 测试续期(dry run,不会真的续期)
- ~/.acme.sh/acme.sh --cron --home ~/.acme.sh --force
复制代码 操作要点
- 无需修改nginx配置:证书路径保持不变,只是证书内容会自动更新
- 不影响现有服务:整个过程只是替换证书文件,不重启服务
- 保留原文件结构:继续使用/data/nginx/ssl/目录
- 自动续期:90天有效期,60天后自动续期
需要你提供的信息
- 腾讯云API密钥:
- 登录腾讯云控制台
- 访问管理 → API密钥管理
- 新建密钥获取SecretId和SecretKey
- 邮箱地址:用于Let's Encrypt通知
安全提醒
- 操作前确保域名的DNS确实在腾讯云解析
- 每一步操作后都用nginx -t测试配置
- 如果出错,可以快速恢复备份:
cp /data/nginx/ssl.backup.$(date +%Y%m%d)/* /data/nginx/ssl/
nginx -s reload
来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |
|
|
|
相关推荐
|
|