Files
ggl/DEPLOYMENT.md
2025-09-23 07:35:11 +00:00

105 lines
2.3 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.

# 宝塔面板 NODE 项目部署说明
## 项目配置
### 端口配置
- 生产环境端口4001
- 端口范围4001-4010可在宝塔面板中调整
### 启动方式
#### 方式一:直接启动(推荐用于宝塔面板)
```bash
npm run start
# 或
npm run start:bt
```
#### 方式二PM2 进程管理
```bash
# 安装 PM2如果未安装
npm install -g pm2
# 启动应用
npm run pm2:start
# 停止应用
npm run pm2:stop
# 重启应用
npm run pm2:restart
```
## 宝塔面板配置步骤
1. **创建 Node.js 项目**
- 在宝塔面板中选择「Node.js项目」
- 项目路径:`/www/wwwroot/ggl`
- 端口4001或4001-4010范围内任意端口
2. **安装依赖**
```bash
npm install
```
3. **构建前端**
```bash
npm run build
```
4. **启动项目**
- 启动文件:`start-production.cjs`
- 或使用启动命令:`npm run start`
## 环境变量配置
在宝塔面板的项目设置中添加以下环境变量:
```
NODE_ENV=production
PORT=4001
JWT_SECRET=your-production-jwt-secret-key-here
```
## 文件结构
```
/www/wwwroot/ggl/
├── api/ # 后端 API
├── src/ # 前端源码
├── dist/ # 前端构建产物
├── uploads/ # 文件上传目录
├── logs/ # 日志目录
├── database.db # SQLite 数据库
├── start-production.cjs # 生产环境启动文件
├── ecosystem.config.js # PM2 配置文件
└── .env.production # 生产环境配置
```
## 注意事项
1. 确保宝塔面板已安装 Node.js 环境(推荐 v18+
2. 确保端口 4001 未被其他服务占用
3. 数据库文件 `database.db` 需要有读写权限
4. `uploads` 目录需要有写入权限
5. 如需修改端口,请同时修改以下文件:
- `api/server.ts`
- `ecosystem.config.js`
- `.env.production`
## 故障排除
### 端口冲突
如果端口 4001 被占用,可以修改为 4002-4010 范围内的其他端口。
### 权限问题
确保项目目录及子目录有正确的读写权限:
```bash
chmod -R 755 /www/wwwroot/ggl
chown -R www:www /www/wwwroot/ggl
```
### 日志查看
- 应用日志:`logs/` 目录
- PM2 日志:`pm2 logs ggl-app`
- 宝塔面板日志:在项目管理页面查看