Files
ggl/BAOTA_DEPLOYMENT.md
2025-10-05 13:34:28 +08:00

191 lines
3.9 KiB
Markdown
Raw 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.

# 梦回高句丽 - 宝塔面板部署指南
## 项目概述
- **项目名称**: 梦回高句丽视频网站
- **域名**: ggl.xi.plus
- **技术栈**: Vue.js + Node.js + Express + SQLite
- **部署方式**: 宝塔面板 NODE 项目
## 部署步骤
### 1. 宝塔面板 NODE 项目配置
#### 基本设置
- **项目名称**: `梦回高句丽`
- **项目路径**: `/www/wwwroot/ggl`
- **启动文件**: `start-production.cjs`
- **运行端口**: `4001` (API) + `4002` (前端)
- **Node.js 版本**: `18.x` 或更高
#### 启动命令配置
```bash
# 在宝塔面板 NODE 项目中设置
启动命令: node start-production.cjs
或者使用 npm 脚本: npm run start:bt
```
### 2. 环境准备
#### 安装依赖
```bash
cd /www/wwwroot/ggl
npm install
```
#### 构建前端项目
```bash
npm run build
```
#### 检查必要文件
确保以下文件存在:
- `dist/` 目录 (前端构建产物)
- `database.db``database/goguryeo_video.db`
- `.env.production` 配置文件
- `logs/` 目录 (自动创建)
### 3. 域名和 SSL 配置
#### 域名绑定
1. 在宝塔面板中添加站点 `ggl.xi.plus`
2. 设置网站目录为 `/www/wwwroot/ggl/dist`
3. 申请并配置 SSL 证书
#### Nginx 配置
使用提供的 `nginx-ggl-xi-plus.conf` 配置文件:
```bash
# 复制配置到宝塔 Nginx 配置目录
cp nginx-ggl-xi-plus.conf /www/server/panel/vhost/nginx/ggl.xi.plus.conf
# 重载 Nginx 配置
nginx -s reload
```
### 4. 启动项目
#### 方式一:宝塔面板 NODE 项目 (推荐)
1. 在宝塔面板 → 软件商店 → Node.js 项目管理
2. 添加项目:
- 项目名称: `梦回高句丽`
- 项目路径: `/www/wwwroot/ggl`
- 启动文件: `start-production.cjs`
- 端口: `4001`
3. 点击启动项目
#### 方式二PM2 管理 (备选)
```bash
# 使用 PM2 启动
npm run pm2:start
# 查看状态
pm2 status
# 查看日志
pm2 logs ggl-xi-plus-production
```
### 5. 验证部署
#### 检查服务状态
```bash
# 检查端口占用
netstat -tlnp | grep :4001
netstat -tlnp | grep :4002
# 检查进程
ps aux | grep node
```
#### 访问测试
- 前端页面: `https://ggl.xi.plus`
- API 接口: `https://ggl.xi.plus/api/health`
- 上传文件: `https://ggl.xi.plus/uploads/`
### 6. 监控和维护
#### 日志文件位置
```
logs/
├── production.log # 应用日志
├── error.log # 错误日志
├── pm2-combined.log # PM2 综合日志
├── pm2-out.log # PM2 输出日志
└── pm2-error.log # PM2 错误日志
```
#### 常用维护命令
```bash
# 重启服务 (宝塔面板)
# 在 NODE 项目管理中点击重启
# 重启服务 (PM2)
npm run pm2:restart
# 查看实时日志
tail -f logs/production.log
# 清理日志
truncate -s 0 logs/*.log
```
### 7. 性能优化配置
#### 系统配置
- **内存限制**: 1GB (可根据实际情况调整)
- **文件上传限制**: 100MB
- **并发连接**: 根据服务器配置调整
- **缓存策略**: 静态资源 1 年API 响应适当缓存
#### 安全配置
- SSL/TLS 加密传输
- CORS 跨域限制
- 请求频率限制
- 敏感文件访问禁止
- 安全响应头设置
## 故障排除
### 常见问题
1. **端口冲突**
```bash
# 检查端口占用
lsof -i :4001
lsof -i :4002
```
2. **权限问题**
```bash
# 设置正确的文件权限
chown -R www:www /www/wwwroot/ggl
chmod -R 755 /www/wwwroot/ggl
```
3. **数据库连接失败**
```bash
# 检查数据库文件权限
ls -la database/
chmod 664 database/*.db
```
4. **前端资源 404**
```bash
# 重新构建前端
npm run build
```
### 联系支持
如遇到部署问题,请检查:
1. Node.js 版本是否符合要求
2. 依赖包是否完整安装
3. 端口是否被占用
4. 文件权限是否正确
5. Nginx 配置是否生效
---
**部署完成后,项目将在 https://ggl.xi.plus 上运行**
**最后更新**: 2024年1月
**维护者**: 系统管理员