370 lines
7.8 KiB
Markdown
370 lines
7.8 KiB
Markdown
|
|
# 完整部署清单 - px.ddn-ai.cloud
|
|||
|
|
|
|||
|
|
## 📋 部署概览
|
|||
|
|
|
|||
|
|
- **服务器**: px.ddn-ai.cloud (124.222.253.158)
|
|||
|
|
- **后端端口**: 8089
|
|||
|
|
- **前端路径**: /admin/
|
|||
|
|
- **数据库**: MySQL (本地)
|
|||
|
|
- **部署时间**: 2026-01-25
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## ✅ 部署步骤
|
|||
|
|
|
|||
|
|
### 第一步: 打包项目
|
|||
|
|
|
|||
|
|
#### 1.1 打包后端
|
|||
|
|
```bash
|
|||
|
|
cd peidu/backend
|
|||
|
|
mvn clean package -DskipTests
|
|||
|
|
```
|
|||
|
|
生成文件: `peidu/backend/target/peidu-backend-1.0.0.jar`
|
|||
|
|
|
|||
|
|
#### 1.2 打包前端
|
|||
|
|
```bash
|
|||
|
|
cd peidu/admin
|
|||
|
|
npm run build
|
|||
|
|
```
|
|||
|
|
生成目录: `peidu/admin/dist/`
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### 第二步: 上传文件到服务器
|
|||
|
|
|
|||
|
|
使用宝塔面板上传以下文件:
|
|||
|
|
|
|||
|
|
#### 2.1 上传后端文件
|
|||
|
|
上传到 `/www/server/java/peidu/`:
|
|||
|
|
- ✅ `peidu-backend-1.0.0.jar` (后端JAR包)
|
|||
|
|
- ✅ `start.sh` (启动脚本)
|
|||
|
|
- ✅ `stop.sh` (停止脚本)
|
|||
|
|
- ✅ `restart.sh` (重启脚本)
|
|||
|
|
|
|||
|
|
#### 2.2 上传前端文件
|
|||
|
|
上传 `peidu/admin/dist/` 目录下的所有文件到 `/www/wwwroot/px.ddn-ai.cloud/admin/`:
|
|||
|
|
- ✅ `index.html`
|
|||
|
|
- ✅ `assets/` 目录及所有文件
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### 第三步: 配置Nginx
|
|||
|
|
|
|||
|
|
#### 3.1 更新Nginx配置
|
|||
|
|
|
|||
|
|
在宝塔面板 → 网站 → px.ddn-ai.cloud → 配置文件,修改为:
|
|||
|
|
|
|||
|
|
```nginx
|
|||
|
|
server {
|
|||
|
|
listen 80;
|
|||
|
|
listen 443 ssl;
|
|||
|
|
listen 443 quic;
|
|||
|
|
listen [::]:443 ssl;
|
|||
|
|
listen [::]:443 quic;
|
|||
|
|
http2 on;
|
|||
|
|
listen [::]:80;
|
|||
|
|
server_name px.ddn-ai.cloud;
|
|||
|
|
index index.html index.htm;
|
|||
|
|
root /www/wwwroot/px.ddn-ai.cloud;
|
|||
|
|
|
|||
|
|
# SSL配置
|
|||
|
|
ssl_certificate /www/server/panel/vhost/cert/px.ddn-ai.cloud/fullchain.pem;
|
|||
|
|
ssl_certificate_key /www/server/panel/vhost/cert/px.ddn-ai.cloud/privkey.pem;
|
|||
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|||
|
|
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384;
|
|||
|
|
ssl_prefer_server_ciphers on;
|
|||
|
|
ssl_session_cache shared:SSL:10m;
|
|||
|
|
ssl_session_timeout 10m;
|
|||
|
|
add_header Strict-Transport-Security "max-age=31536000";
|
|||
|
|
error_page 497 https://$host$request_uri;
|
|||
|
|
|
|||
|
|
# 错误页面
|
|||
|
|
error_page 404 /404.html;
|
|||
|
|
error_page 502 /502.html;
|
|||
|
|
|
|||
|
|
# 后端API代理配置 (重要!)
|
|||
|
|
location /api/ {
|
|||
|
|
proxy_pass http://127.0.0.1:8089/api/;
|
|||
|
|
proxy_set_header Host $host;
|
|||
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|||
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|||
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|||
|
|
proxy_connect_timeout 30s;
|
|||
|
|
proxy_send_timeout 30s;
|
|||
|
|
proxy_read_timeout 30s;
|
|||
|
|
|
|||
|
|
# 支持WebSocket(如果需要)
|
|||
|
|
proxy_http_version 1.1;
|
|||
|
|
proxy_set_header Upgrade $http_upgrade;
|
|||
|
|
proxy_set_header Connection "upgrade";
|
|||
|
|
|
|||
|
|
# CORS配置(重要:微信小程序需要)
|
|||
|
|
add_header Access-Control-Allow-Origin *;
|
|||
|
|
add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
|
|||
|
|
add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization';
|
|||
|
|
add_header Access-Control-Expose-Headers 'Content-Length,Content-Range';
|
|||
|
|
|
|||
|
|
# 处理OPTIONS预检请求
|
|||
|
|
if ($request_method = 'OPTIONS') {
|
|||
|
|
add_header Access-Control-Allow-Origin *;
|
|||
|
|
add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
|
|||
|
|
add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization';
|
|||
|
|
add_header Access-Control-Max-Age 1728000;
|
|||
|
|
add_header Content-Type 'text/plain; charset=utf-8';
|
|||
|
|
add_header Content-Length 0;
|
|||
|
|
return 204;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# 前端管理界面配置
|
|||
|
|
location /admin/ {
|
|||
|
|
alias /www/wwwroot/px.ddn-ai.cloud/admin/;
|
|||
|
|
try_files $uri $uri/ /admin/index.html;
|
|||
|
|
|
|||
|
|
# 缓存配置
|
|||
|
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
|
|||
|
|
expires 1y;
|
|||
|
|
add_header Cache-Control "public, immutable";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# 禁止访问敏感文件
|
|||
|
|
location ~ ^/(\.user.ini|\.htaccess|\.git|\.env|\.svn|\.project|LICENSE|README.md) {
|
|||
|
|
return 404;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# 静态资源缓存
|
|||
|
|
location ~ \.well-known {
|
|||
|
|
allow all;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
location ~ \.(gif|jpg|jpeg|png|bmp|swf|webp)$ {
|
|||
|
|
expires 30d;
|
|||
|
|
access_log off;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
location ~ \.(js|css|woff|woff2|ttf|eot)$ {
|
|||
|
|
expires 12h;
|
|||
|
|
access_log off;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# 日志配置
|
|||
|
|
access_log /www/wwwlogs/px.ddn-ai.cloud.log;
|
|||
|
|
error_log /www/wwwlogs/px.ddn-ai.cloud.error.log;
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### 3.2 重载Nginx
|
|||
|
|
```bash
|
|||
|
|
nginx -t
|
|||
|
|
nginx -s reload
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### 第四步: 设置文件权限
|
|||
|
|
|
|||
|
|
在宝塔终端执行:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 设置后端脚本权限
|
|||
|
|
cd /www/server/java/peidu
|
|||
|
|
chmod +x start.sh stop.sh restart.sh
|
|||
|
|
|
|||
|
|
# 设置前端文件权限
|
|||
|
|
chmod -R 755 /www/wwwroot/px.ddn-ai.cloud/admin
|
|||
|
|
chown -R www:www /www/wwwroot/px.ddn-ai.cloud/admin
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### 第五步: 启动后端服务
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
cd /www/server/java/peidu
|
|||
|
|
./start.sh
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
查看日志:
|
|||
|
|
```bash
|
|||
|
|
tail -f /www/server/java/peidu/logs/app.log
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
看到 `Started PeiduApplication in xxx seconds` 表示启动成功!
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### 第六步: 验证部署
|
|||
|
|
|
|||
|
|
#### 6.1 检查后端进程
|
|||
|
|
```bash
|
|||
|
|
ps aux | grep peidu-backend
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### 6.2 检查端口监听
|
|||
|
|
```bash
|
|||
|
|
netstat -tlnp | grep 8089
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### 6.3 测试后端API
|
|||
|
|
```bash
|
|||
|
|
# 测试本地访问
|
|||
|
|
curl http://localhost:8089/api/health
|
|||
|
|
|
|||
|
|
# 测试通过Nginx访问
|
|||
|
|
curl https://px.ddn-ai.cloud/api/health
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### 6.4 测试前端访问
|
|||
|
|
浏览器访问: `https://px.ddn-ai.cloud/admin/`
|
|||
|
|
|
|||
|
|
应该能看到登录页面!
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 🔍 故障排查
|
|||
|
|
|
|||
|
|
### 问题1: 后端无法启动
|
|||
|
|
|
|||
|
|
**检查步骤**:
|
|||
|
|
```bash
|
|||
|
|
# 查看日志
|
|||
|
|
tail -n 100 /www/server/java/peidu/logs/app.log
|
|||
|
|
|
|||
|
|
# 检查端口占用
|
|||
|
|
netstat -tlnp | grep 8089
|
|||
|
|
|
|||
|
|
# 检查Java版本
|
|||
|
|
java -version
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 问题2: 前端404错误
|
|||
|
|
|
|||
|
|
**检查步骤**:
|
|||
|
|
```bash
|
|||
|
|
# 检查文件是否存在
|
|||
|
|
ls -la /www/wwwroot/px.ddn-ai.cloud/admin/
|
|||
|
|
|
|||
|
|
# 检查Nginx配置
|
|||
|
|
nginx -t
|
|||
|
|
|
|||
|
|
# 查看Nginx错误日志
|
|||
|
|
tail -f /www/wwwlogs/px.ddn-ai.cloud.error.log
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 问题3: API调用失败
|
|||
|
|
|
|||
|
|
**检查步骤**:
|
|||
|
|
```bash
|
|||
|
|
# 检查后端是否运行
|
|||
|
|
ps aux | grep peidu-backend
|
|||
|
|
|
|||
|
|
# 测试后端直接访问
|
|||
|
|
curl http://localhost:8089/api/health
|
|||
|
|
|
|||
|
|
# 测试Nginx代理
|
|||
|
|
curl https://px.ddn-ai.cloud/api/health
|
|||
|
|
|
|||
|
|
# 查看Nginx日志
|
|||
|
|
tail -f /www/wwwlogs/px.ddn-ai.cloud.log
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 📝 常用命令
|
|||
|
|
|
|||
|
|
### 后端管理
|
|||
|
|
```bash
|
|||
|
|
# 启动
|
|||
|
|
cd /www/server/java/peidu && ./start.sh
|
|||
|
|
|
|||
|
|
# 停止
|
|||
|
|
cd /www/server/java/peidu && ./stop.sh
|
|||
|
|
|
|||
|
|
# 重启
|
|||
|
|
cd /www/server/java/peidu && ./restart.sh
|
|||
|
|
|
|||
|
|
# 查看日志
|
|||
|
|
tail -f /www/server/java/peidu/logs/app.log
|
|||
|
|
|
|||
|
|
# 查看进程
|
|||
|
|
ps aux | grep peidu-backend
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### Nginx管理
|
|||
|
|
```bash
|
|||
|
|
# 测试配置
|
|||
|
|
nginx -t
|
|||
|
|
|
|||
|
|
# 重载配置
|
|||
|
|
nginx -s reload
|
|||
|
|
|
|||
|
|
# 重启Nginx
|
|||
|
|
systemctl restart nginx
|
|||
|
|
|
|||
|
|
# 查看日志
|
|||
|
|
tail -f /www/wwwlogs/px.ddn-ai.cloud.log
|
|||
|
|
tail -f /www/wwwlogs/px.ddn-ai.cloud.error.log
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 系统监控
|
|||
|
|
```bash
|
|||
|
|
# 查看内存
|
|||
|
|
free -h
|
|||
|
|
|
|||
|
|
# 查看CPU
|
|||
|
|
top
|
|||
|
|
|
|||
|
|
# 查看磁盘
|
|||
|
|
df -h
|
|||
|
|
|
|||
|
|
# 查看端口
|
|||
|
|
netstat -tlnp
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## ✅ 部署检查清单
|
|||
|
|
|
|||
|
|
部署完成后,请逐项检查:
|
|||
|
|
|
|||
|
|
- [ ] 后端JAR包已上传
|
|||
|
|
- [ ] 启动脚本已上传并设置执行权限
|
|||
|
|
- [ ] 前端文件已上传到admin目录
|
|||
|
|
- [ ] Nginx配置已更新(API代理到127.0.0.1:8089)
|
|||
|
|
- [ ] Nginx配置已重载
|
|||
|
|
- [ ] 后端服务已启动
|
|||
|
|
- [ ] 后端进程正在运行
|
|||
|
|
- [ ] 端口8089正在监听
|
|||
|
|
- [ ] 后端API可以访问(curl测试)
|
|||
|
|
- [ ] 前端页面可以访问(浏览器测试)
|
|||
|
|
- [ ] 前端可以调用后端API
|
|||
|
|
- [ ] 登录功能正常
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 🎯 访问地址
|
|||
|
|
|
|||
|
|
- **管理后台**: https://px.ddn-ai.cloud/admin/
|
|||
|
|
- **后端API**: https://px.ddn-ai.cloud/api/
|
|||
|
|
- **测试账号**:
|
|||
|
|
- 手机号: 13800138001
|
|||
|
|
- 密码: 123456
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 📞 需要帮助?
|
|||
|
|
|
|||
|
|
如果遇到问题:
|
|||
|
|
1. 查看日志文件
|
|||
|
|
2. 检查进程和端口
|
|||
|
|
3. 测试各个环节
|
|||
|
|
4. 记录错误信息
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
**创建时间**: 2026-01-25
|
|||
|
|
**服务器**: px.ddn-ai.cloud (124.222.253.158)
|
|||
|
|
**后端端口**: 8089
|
|||
|
|
**前端路径**: /admin/
|