1.9 KiB
1.9 KiB
部署说明
环境
- AlmaLinux 9
- Nginx
- Cloudflare CDN
- Cloudflare SSL/TLS:
Full (strict)
网站是纯静态文件,不需要数据库、Node.js 服务或常驻应用进程。
生成发布包
在仓库根目录执行:
Compress-Archive -Path .\site\* -DestinationPath .\midctrl-homepage-public.zip -CompressionLevel Optimal
Get-FileHash .\midctrl-homepage-public.zip -Algorithm SHA256
发布 ZIP 不应提交到 Git。
部署网站文件
将 ZIP 上传后解压到独立网站目录:
mkdir -p /var/www/midctrl.com
unzip -o /root/midctrl-homepage-public.zip -d /var/www/midctrl.com
chown -R root:nginx /var/www/midctrl.com
find /var/www/midctrl.com -type d -exec chmod 755 {} \;
find /var/www/midctrl.com -type f -exec chmod 644 {} \;
如果 SELinux 已启用,再执行:
restorecon -Rv /var/www/midctrl.com
Nginx
nginx/midctrl.com.example.conf 是公开、脱敏的参考模板。不要直接覆盖生产配置。部署时需要:
- 将现有站点
root指向/var/www/midctrl.com。 - 合并安全响应头、缓存和 gzip 规则。
- 保留服务器现有的所有私有 location 和代理请求头。
- 保留有效的 Cloudflare Origin Certificate 路径。
- 确认字体使用
font/woff2或兼容的 MIME 类型。
生效前必须执行:
nginx -t
systemctl reload nginx
只有 nginx -t 成功后才能 reload。
部署后检查
- 首页和 404 页面正常。
- Blog 与 Tools 在新标签页打开。
- Noto Serif SC 字体返回 200。
- 控制台无 JavaScript、WebGL 或资源错误。
- Sakura 在前台页面持续运动,页面进入后台后暂停并能恢复。
- 服务器原有私有服务仍正常。
- 仓库 README、测试和 Nginx 示例没有出现在网站根目录。
回滚
部署前备份当前网站目录和 Nginx 配置。发生问题时恢复备份,运行 nginx -t,成功后 reload。不要把生产备份提交到 Git。