117 lines
3.0 KiB
Markdown
117 lines
3.0 KiB
Markdown
|
|
# 端口修改指南(8082 → 18082)
|
|||
|
|
|
|||
|
|
## ✅ 已完成的代码修改
|
|||
|
|
|
|||
|
|
以下文件已自动修改:
|
|||
|
|
|
|||
|
|
1. **后端配置文件**
|
|||
|
|
- `mt-pay/src/main/resources/application-dev.yml`: `server.port: 18082`
|
|||
|
|
- `mt-pay/src/main/resources/application-prod.yml`: `server.port: ${server.port:18082}`
|
|||
|
|
- `application-dev.yml`: `paypal.webhook-url: http://175.178.252.59:18082/api/paypal/webhook`
|
|||
|
|
|
|||
|
|
2. **Java代码**
|
|||
|
|
- `ProductServiceImpl.java`: `@Value("${server.port:18082}")`
|
|||
|
|
|
|||
|
|
3. **前端配置**
|
|||
|
|
- `vite.config.js`: 开发环境代理端口改为 `18082`
|
|||
|
|
|
|||
|
|
4. **部署文档**
|
|||
|
|
- `DEPLOYMENT_README.md`: 所有端口引用已更新
|
|||
|
|
|
|||
|
|
## ⚠️ 需要手动操作
|
|||
|
|
|
|||
|
|
### 1. 重新打包后端
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
cd E:\MTKJPAY
|
|||
|
|
mvn clean package -DskipTests
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 2. 在宝塔中修改Nginx配置
|
|||
|
|
|
|||
|
|
**重要:** 必须修改Nginx配置文件中的 `proxy_pass` 端口!
|
|||
|
|
|
|||
|
|
找到Nginx配置文件(通常在宝塔面板 → 网站 → 设置 → 配置文件),修改:
|
|||
|
|
|
|||
|
|
**修改前:**
|
|||
|
|
```nginx
|
|||
|
|
location /api/ {
|
|||
|
|
proxy_pass http://127.0.0.1:8082;
|
|||
|
|
proxy_set_header Host $host;
|
|||
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|||
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
**修改后:**
|
|||
|
|
```nginx
|
|||
|
|
location /api/ {
|
|||
|
|
proxy_pass http://127.0.0.1:18082;
|
|||
|
|
proxy_set_header Host $host;
|
|||
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|||
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
修改后,在宝塔面板中:
|
|||
|
|
1. 点击"保存"
|
|||
|
|
2. 点击"重载配置"或"重启Nginx"
|
|||
|
|
|
|||
|
|
### 3. 更新PayPal Webhook URL(如果已配置)
|
|||
|
|
|
|||
|
|
如果已经在PayPal控制台配置了Webhook,需要更新URL:
|
|||
|
|
- 旧URL: `http://175.178.252.59:8082/api/paypal/webhook`
|
|||
|
|
- 新URL: `http://175.178.252.59:18082/api/paypal/webhook`
|
|||
|
|
|
|||
|
|
### 4. 检查防火墙
|
|||
|
|
|
|||
|
|
确保服务器防火墙已开放新端口 `18082`:
|
|||
|
|
- 宝塔面板 → 安全 → 添加端口规则:`18082`
|
|||
|
|
|
|||
|
|
### 5. 上传并启动新的jar包
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 上传新的jar包到服务器
|
|||
|
|
# 停止旧进程(如果正在运行)
|
|||
|
|
# 启动新进程
|
|||
|
|
java -jar mt-pay-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev
|
|||
|
|
|
|||
|
|
# 或后台运行
|
|||
|
|
nohup java -jar mt-pay-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev > app.log 2>&1 &
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 验证
|
|||
|
|
|
|||
|
|
1. **检查后端是否启动成功**
|
|||
|
|
```bash
|
|||
|
|
# 在服务器上执行
|
|||
|
|
netstat -tlnp | grep 18082
|
|||
|
|
# 或
|
|||
|
|
curl http://127.0.0.1:18082/api/health
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
2. **检查Nginx代理是否正常**
|
|||
|
|
```bash
|
|||
|
|
# 在服务器上执行
|
|||
|
|
curl http://127.0.0.1/api/health
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
3. **浏览器测试**
|
|||
|
|
- 访问前端页面
|
|||
|
|
- 打开浏览器控制台(F12)
|
|||
|
|
- 检查Network标签中的API请求
|
|||
|
|
- 应该能正常访问 `/api/xxx` 接口
|
|||
|
|
|
|||
|
|
## 总结
|
|||
|
|
|
|||
|
|
**必须完成的操作:**
|
|||
|
|
1. ✅ 代码已修改(已完成)
|
|||
|
|
2. ⚠️ **重新打包后端**(必须)
|
|||
|
|
3. ⚠️ **修改Nginx配置**(必须)
|
|||
|
|
4. ⚠️ **上传新jar包并重启**(必须)
|
|||
|
|
5. ⚠️ **更新PayPal Webhook URL**(如果已配置)
|
|||
|
|
6. ⚠️ **开放防火墙端口**(必须)
|
|||
|
|
|
|||
|
|
**注意:** 只修改代码是不够的,必须重新打包并修改Nginx配置!
|
|||
|
|
|