guoyu/Test/md/部署配置说明.md

303 lines
7.2 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.

# 部署配置修改说明
## ✅ 已完成的配置修改
### **1. 后端配置Spring Boot**
#### **文件:`Study-Vue-redis/ry-study-admin/src/main/resources/application.yml`**
```yaml
# 服务器端口(不变)
server:
port: 30091
# 文件上传路径(根据服务器实际文件位置配置)
# 注意RuoYiConfig.getUploadPath() 会自动在 profile 后面加上 /upload
# 实际上传路径 = profile + /upload = D:\wwwroot\study_web\web\profile\upload
ruoyi:
profile: D:\wwwroot\study_web\web\profile
```
#### **文件:`Study-Vue-redis/ry-study-admin/src/main/resources/application-druid.yml`**
```yaml
# 数据库连接
spring:
datasource:
druid:
master:
url: jdbc:mysql://127.0.0.1:3306/study?...
username: study # ✅ 已修改
password: rx4aywZZNP3rnrkm # ✅ 已修改
```
---
### **2. 前端配置uni-app**
#### **文件:`fronted_uniapp/utils/config.js`**
```javascript
const DEFAULT_SERVER_HOST = '192.168.0.106' // ✅ 已修改
const DEFAULT_SERVER_PORT = 30091
const DEV_SERVER_HOST = '192.168.0.106' // ✅ 已修改
const DEV_SERVER_PORT = 30091
```
#### **文件:`fronted_uniapp/App.vue`**
```javascript
const APP_DEV_HOST = '192.168.0.106' // ✅ 已修改
const APP_DEV_PORT = 30091
const PROD_HOST = '192.168.0.106' // ✅ 已修改
const PROD_PORT = 30091
```
#### **文件:`fronted_uniapp/vite.config.js`**
```javascript
proxy: {
'/api': {
target: 'http://192.168.0.106:30091', // ✅ 已修改
},
'/ws': {
target: 'http://192.168.0.106:30091', // ✅ 已修改
}
}
```
---
### **3. 管理后台配置Vue**
#### **文件:`Study-Vue-redis/ry-study-ui/vue.config.js`**
```javascript
const baseUrl = process.env.VUE_APP_BASE_URL ||
(process.env.NODE_ENV === 'production'
? 'http://192.168.0.106:30091' // ✅ 已修改
: 'http://192.168.0.106:30091') // ✅ 已修改
const port = 20002 // 管理界面端口访问地址http://192.168.0.106:20002
```
---
## 📊 部署信息总结
### **服务器地址:**
- **新服务器IP**`192.168.0.106`
- **后端API端口**`30091`(不变)
- **管理界面端口**`20002`(开发环境)或 `8080`(生产部署)
### **文件路径:**
- **配置路径**`D:\wwwroot\study_web\web\profile`
- **实际存储示例**`D:\wwwroot\study_web\web\profile\upload\2025\11\18\xxx.mp4`
- **数据库存储格式**`/profile/upload/2025/11/18/xxx.mp4`
- **访问URL示例**`http://192.168.0.106:30091/profile/upload/2025/11/18/xxx.mp4`
- **说明**profile配置会自动加上/upload所以实际上传路径是 profile + /upload
### **数据库连接:**
- **地址**`127.0.0.1:3306`(本地)
- **数据库名**`study`
- **用户名**`study`
- **密码**`rx4aywZZNP3rnrkm`
---
## 🚀 部署步骤
### **1. 重新打包后端**
```bash
cd Study-Vue-redis
mvn clean package -DskipTests
```
生成文件:`ry-study-admin/target/ry-study-admin.jar`
### **2. 启动后端服务**
```bash
cd ry-study-admin/target
java -jar ry-study-admin.jar
```
**或使用后台运行:**
```bash
nohup java -jar ry-study-admin.jar > app.log 2>&1 &
```
**验证:** 访问 `http://192.168.0.106:30091`
---
### **3. 部署管理后台(可选)**
#### **开发环境运行:**
```bash
cd Study-Vue-redis/ry-study-ui
npm install
npm run dev
```
访问:`http://192.168.0.106:20002`
#### **生产环境部署:**
```bash
npm run build:prod
```
`dist` 目录部署到Web服务器如Nginx
- 配置访问端口为 `8080`
- 配置反向代理到后端API `30091`
---
### **4. 打包uni-app**
#### **Android APK**
1. HBuilderX → 发行 → 原生App-云打包
2. 选择Android
3. 打包
#### **iOS**
1. HBuilderX → 发行 → 原生App-云打包
2. 选择iOS
3. 需要Apple开发者账号
---
## 📝 验证清单
### **后端验证:**
- [ ] 启动Spring Boot服务
- [ ] 访问 `http://192.168.0.106:30091`
- [ ] 测试登录功能
- [ ] 测试文件上传
- [ ] 验证文件访问:`http://192.168.0.106:30091/profile/upload/2025/12/07/xxx.mp4`
### **管理后台验证:**
- [ ] 启动Vue开发服务器或部署Nginx
- [ ] 访问 `http://192.168.0.106:8080`或20002
- [ ] 测试登录
- [ ] 测试课件管理
- [ ] 验证文件显示
### **uni-app验证**
- [ ] 重新编译APP
- [ ] 安装到手机
- [ ] 测试登录
- [ ] 测试课程列表
- [ ] 测试视频播放
- [ ] 测试语音评测
---
## ⚠️ 注意事项
### **1. 防火墙配置**
确保服务器防火墙开放端口:
- `30091`后端API
- `8080`:管理后台(如果单独部署)
- `3306`MySQL如果远程访问
### **2. 文件路径权限**
确保Spring Boot进程有权限访问
```
D:\wwwroot\study_web\web\profile\
```
**重要:验证文件路径映射**
```
【文件访问】
数据库存储:/profile/upload/2025/11/18/02.妙解成语——对牛弹琴.mp4
配置路径: D:\wwwroot\study_web\web\profile
完整路径: D:\wwwroot\study_web\web\profile + /upload/2025/11/18/02.妙解成语——对牛弹琴.mp4
= D:\wwwroot\study_web\web\profile\upload\2025\11\18\02.妙解成语——对牛弹琴.mp4 ✅
【文件上传】
上传路径: getUploadPath() = profile + "/upload"
= D:\wwwroot\study_web\web\profile + /upload
= D:\wwwroot\study_web\web\profile\upload ✅
```
### **3. 数据库访问**
如果数据库需要远程访问修改MySQL配置
```sql
GRANT ALL PRIVILEGES ON study.* TO 'study'@'%' IDENTIFIED BY 'rx4aywZZNP3rnrkm';
FLUSH PRIVILEGES;
```
### **4. Nginx配置生产环境**
#### **管理后台8080端口**
```nginx
server {
listen 8080;
server_name 192.168.0.106;
root D:/wwwroot/study_web/ry-study-ui/dist;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
# 代理API请求
location /dev-api/ {
proxy_pass http://127.0.0.1:30091/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
# 代理文件访问
location /profile/ {
proxy_pass http://127.0.0.1:30091/profile/;
}
}
```
#### **文件直接访问(可选):**
```nginx
location /profile/ {
alias D:/wwwroot/study_web/web/profile/;
autoindex off;
}
```
---
## 📞 常见问题
### **Q1: 后端启动失败**
- 检查端口30091是否被占用
- 检查数据库连接是否正常
- 查看日志文件
### **Q2: 文件无法访问**
- 检查文件路径配置是否正确
- 检查文件是否存在
- 检查文件权限
### **Q3: uni-app连接失败**
- 检查手机和服务器是否在同一局域网
- 检查防火墙设置
- 清除APP缓存重新安装
### **Q4: 管理后台登录失败**
- 检查后端服务是否运行
- 检查网络连接
- F12查看浏览器控制台错误
---
## ✅ 部署完成检查
完成以下所有检查后,系统即可正常使用:
1. ✅ 后端服务运行在 `http://192.168.0.106:30091`
2. ✅ 管理后台访问 `http://192.168.0.106:8080`
3. ✅ 数据库连接正常
4. ✅ 文件上传和访问正常
5. ✅ uni-app可以连接后端
6. ✅ 所有功能测试通过
---
**配置修改完成时间:** 2025-12-07
**修改内容:** 服务器地址从 `192.168.1.80` 改为 `192.168.0.106`,数据库账号密码更新