Files

49 lines
1.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# SSL 证书自动更新脚本
一键把腾讯云下载的 SSL 证书更新到服务器上,并自动重启 nginx。
## 使用前准备
1. 从腾讯云后台下载 nginx 格式的证书压缩包(如 `ayi-games.online_nginx.zip`)。
2. 把压缩包放到本机的 **下载(Downloads** 文件夹。
3. 本机需要能免密登录服务器(已配置好 SSH 密钥)。
## 使用方法
### 方式一:Windows 双击运行(推荐)
1. 在 Windows 上同步仓库(`git pull`)。
2. 双击 `update-ssl.bat`
3. 脚本会自动打开 Git Bash 并运行,完成后按任意键关闭窗口。
### 方式二:终端运行(Mac / Linux)
在终端里运行:
```bash
./update-ssl.sh
```
脚本会自动完成以下事情:
1. 找到「下载」文件夹里所有 `*_nginx.zip` 压缩包。
2. 逐个上传到服务器,解压并覆盖 `~/certs` 里的旧证书。
3. 自动重启 nginx 让新证书生效。
4. 删除服务器和本机「下载」里的压缩包。
看到 `Done. All SSL certs updated and nginx reloaded.` 就说明更新成功了。
## 注意事项
- 一次可以放多个证书压缩包,脚本会全部处理。
- 如果「下载」里没有压缩包,脚本会报错并退出,不会误删任何文件。
- 证书文件会解压到服务器的 `~/certs` 目录(忽略压缩包内的子文件夹)。
- 更新完成后,本机「下载」里的压缩包会被自动删除。
## 常见问题
**提示找不到压缩包?**
确认压缩包文件名以 `_nginx.zip` 结尾,并且放在「下载」文件夹里。
**需要 sudo 密码?**
如果服务器登录用户没有免密 sudo,脚本执行到重启 nginx 时会提示输入密码。