Files
MTKJPAY/PORT_CHANGE_GUIDE.md
qiube 56ae5a5892 chore(config): 更新服务器端口配置从8082到18082
- 修改application-dev.yml和application-prod.yml中的server.port配置
- 更新PayPal webhook URL中的端口号
- 修改DEPLOYMENT_README.md中的端口引用信息
- 更新ProductServiceImpl.java中的端口配置注入
- 创建PORT_CHANGE_GUIDE.md提供端口修改操作指南
- 更新部署文档中的防火墙端口和Nginx配置说明
2025-12-26 13:43:26 +08:00

117 lines
3.0 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.
# 端口修改指南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配置