Files
yuyuecha-guanwang/DEPLOY.md
T

251 lines
6.9 KiB
Markdown

# DEPLOY.md - 愉悦查官网 (yuyuecha.com.cn) 更新部署
## 项目信息
- **项目名称**: 愉悦查官网 V2.0 更新
- **域名**: yuyuecha.com.cn / www.yuyuecha.com.cn
- **更新内容**: 全站导航栏/Footer统一、Logo优化、SEO标签注入、GEO文件部署
- **部署包**: yuyuecha_fixed.tar.gz
---
## 第一步:备份现有网站
> ⚠️ 必须先完成备份,确认备份文件完整后再进行部署。
```bash
# 1. 进入网站根目录(根据实际路径调整)
cd /www/wwwroot/yuyuecha.com.cn
# 2. 创建带时间戳的备份目录
BACKUP_DIR="/www/backup/yuyuecha_$(date +%Y%m%d_%H%M%S)"
mkdir -p "$BACKUP_DIR"
# 3. 完整备份当前网站
cp -r /www/wwwroot/yuyuecha.com.cn/* "$BACKUP_DIR/"
cp -r /www/wwwroot/yuyuecha.com.cn/.* "$BACKUP_DIR/" 2>/dev/null
# 4. 同时打一个 tar 包备份
tar czf "${BACKUP_DIR}.tar.gz" -C /www/wwwroot yuyuecha.com.cn/
# 5. 验证备份完整性
echo "=== 备份验证 ==="
echo "备份目录: $BACKUP_DIR"
echo "备份文件数: $(find "$BACKUP_DIR" -type f | wc -l)"
echo "备份大小: $(du -sh "$BACKUP_DIR" | cut -f1)"
echo "tar包大小: $(ls -lh "${BACKUP_DIR}.tar.gz" | awk '{print $5}')"
ls -la "$BACKUP_DIR"/index.html && echo "✅ 备份验证通过" || echo "❌ 备份异常,停止部署"
```
**检查点**: 确认输出显示 `✅ 备份验证通过` 后再继续。如果显示 `❌ 备份异常`,停止执行并报告错误。
---
## 第二步:下载并解压新版代码
```bash
# 1. 进入临时目录
cd /tmp
# 2. 下载新版部署包(二选一,根据实际文件位置)
# 方式A:从本地上传路径复制
cp /path/to/yuyuecha_fixed.tar.gz /tmp/
# 方式B:如果已放到服务器上的某个路径
# cp /root/yuyuecha_fixed.tar.gz /tmp/
# 3. 解压到临时目录
tar xzf /tmp/yuyuecha_fixed.tar.gz -C /tmp/
# 4. 检查解压结果
echo "=== 新版文件检查 ==="
ls -la /tmp/yuyuecha/index.html
ls -la /tmp/yuyuecha/llms.txt
ls -la /tmp/yuyuecha/assets/logo-nav.png
echo "文件总数: $(find /tmp/yuyuecha -type f | wc -l)"
```
---
## 第三步:部署新版网站
```bash
# 1. 进入网站根目录
cd /www/wwwroot/yuyuecha.com.cn
# 2. 先删除旧的备份文件(.bak文件,节省空间)
find . -name "*.bak.*" -delete
find . -name "*.broken.*" -delete
find . -name "*.backup" -delete
find . -name "*.restored" -delete
# 3. 覆盖部署新版文件
# 使用 rsync 保留未修改的文件,只更新变化的部分
rsync -av --exclude='.git' --exclude='*.bak.*' /tmp/yuyuecha/ /www/wwwroot/yuyuecha.com.cn/
# 4. 确保文件权限正确
chown -R www:www /www/wwwroot/yuyuecha.com.cn/
chmod -R 755 /www/wwwroot/yuyuecha.com.cn/
chmod 644 /www/wwwroot/yuyuecha.com.cn/*.html
chmod 644 /www/wwwroot/yuyuecha.com.cn/product/*.html
chmod 644 /www/wwwroot/yuyuecha.com.cn/assets/*.png
chmod 644 /www/wwwroot/yuyuecha.com.cn/robots.txt
chmod 644 /www/wwwroot/yuyuecha.com.cn/sitemap.xml
chmod 644 /www/wwwroot/yuyuecha.com.cn/llms.txt
```
---
## 第四步:部署验证
```bash
echo "========================================="
echo " 愉悦查官网部署验证"
echo "========================================="
SITE_ROOT="/www/wwwroot/yuyuecha.com.cn"
ERRORS=0
# 1. 核心文件存在性检查
echo ""
echo "[1/5] 核心文件检查..."
for f in index.html about.html contact.html careers.html news.html partners.html \
investment.html help.html disclaimer.html privacy.html terms.html \
sample.html all-apis.html sitemap.xml robots.txt llms.txt; do
if [ -f "$SITE_ROOT/$f" ]; then
echo " ✅ $f"
else
echo " ❌ $f 缺失!"
ERRORS=$((ERRORS+1))
fi
done
# 2. 产品页检查
echo ""
echo "[2/5] 产品页检查..."
for f in riskassessment.html marriage.html backgroundcheck.html \
companyinfo.html homeservice.html consumerFinanceReport.html; do
if [ -f "$SITE_ROOT/product/$f" ]; then
echo " ✅ product/$f"
else
echo " ❌ product/$f 缺失!"
ERRORS=$((ERRORS+1))
fi
done
# 3. 新增资源检查
echo ""
echo "[3/5] 新增资源检查..."
for f in assets/logo-nav.png assets/logo-nav-2x.png; do
if [ -f "$SITE_ROOT/$f" ]; then
SIZE=$(ls -lh "$SITE_ROOT/$f" | awk '{print $5}')
echo " ✅ $f ($SIZE)"
else
echo " ❌ $f 缺失!"
ERRORS=$((ERRORS+1))
fi
done
# 4. SEO/GEO 标签验证
echo ""
echo "[4/5] SEO/GEO 标签验证..."
if grep -q 'rel="canonical"' "$SITE_ROOT/index.html"; then
echo " ✅ Canonical 标签已注入"
else
echo " ❌ Canonical 标签缺失"
ERRORS=$((ERRORS+1))
fi
if grep -q 'og:title' "$SITE_ROOT/index.html"; then
echo " ✅ Open Graph 标签已注入"
else
echo " ❌ Open Graph 标签缺失"
ERRORS=$((ERRORS+1))
fi
if grep -q 'GPTBot' "$SITE_ROOT/robots.txt"; then
echo " ✅ robots.txt AI爬虫已放行"
else
echo " ❌ robots.txt AI爬虫配置缺失"
ERRORS=$((ERRORS+1))
fi
if grep -q 'riskassessment.html' "$SITE_ROOT/sitemap.xml"; then
echo " ✅ sitemap.xml 路径已修正"
else
echo " ❌ sitemap.xml 路径异常"
ERRORS=$((ERRORS+1))
fi
# 5. HTTP 访问测试
echo ""
echo "[5/5] HTTP 访问测试..."
for url in "https://www.yuyuecha.com.cn/" \
"https://www.yuyuecha.com.cn/llms.txt" \
"https://www.yuyuecha.com.cn/sitemap.xml" \
"https://www.yuyuecha.com.cn/robots.txt"; do
STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$url" --max-time 10)
if [ "$STATUS" = "200" ]; then
echo " ✅ $url$STATUS"
else
echo " ⚠️ $url$STATUS"
ERRORS=$((ERRORS+1))
fi
done
# 结果汇总
echo ""
echo "========================================="
if [ $ERRORS -eq 0 ]; then
echo " 🎉 部署验证全部通过!"
else
echo " ⚠️ 发现 $ERRORS 个问题,请检查"
fi
echo "========================================="
```
---
## 第五步:清理临时文件
```bash
# 部署验证通过后,清理临时文件
rm -rf /tmp/yuyuecha
rm -f /tmp/yuyuecha_fixed.tar.gz
echo "✅ 临时文件已清理"
echo "✅ 备份保存在: $BACKUP_DIR"
echo "✅ 部署完成"
```
---
## 回滚方案
如果部署后发现问题,执行以下命令回滚到备份版本:
```bash
# 找到最新的备份目录
LATEST_BACKUP=$(ls -td /www/backup/yuyuecha_* | head -1)
echo "回滚到: $LATEST_BACKUP"
# 回滚
rsync -av --delete "$LATEST_BACKUP/" /www/wwwroot/yuyuecha.com.cn/
chown -R www:www /www/wwwroot/yuyuecha.com.cn/
echo "✅ 已回滚到备份版本"
```
---
## 本次更新内容清单
| 类别 | 文件 | 变更说明 |
|------|------|----------|
| 新增 | assets/logo-nav.png | 导航栏优化Logo (18KB) |
| 新增 | assets/logo-nav-2x.png | 2x Retina版 (63KB) |
| 新增 | llms.txt | GEO AI爬虫入口文件 |
| 新增 | 推广优化方案.md | SEO+GEO推广方案 |
| 修改 | sitemap.xml | 修复全部404路径,覆盖20个页面 |
| 修改 | robots.txt | 添加AI爬虫(GPTBot/ClaudeBot等)许可 |
| 修改 | 19个HTML页面 | 导航栏统一 + Footer统一 + OG/Canonical/Twitter标签 |