优化项目部署

This commit is contained in:
2026-03-21 14:33:14 +08:00
parent 9178fd643b
commit 3502c299d1
3 changed files with 32 additions and 19 deletions

View File

@@ -180,18 +180,42 @@ php webman migrate
```
3. **访问地址:**
- 安装向导http://localhost:1818/install/
- 前台地址http://localhost:1818/index.html/#/
- 后台地址http://localhost:1818/index.html/#/admin
- 安装向导http://localhost:1818/install/
- 前台地址http://localhost:1818/index.html/#/
- 后台地址http://localhost:1818/index.html/#/admin
> 注意:前端通过 Vite 代理将 `/api`、`/admin`、`/install` 转发到后端 8787 端口,请勿直接访问 8787 端口的前端页面,否则可能出现 404。
### 5.6 生产环境 Nginx反向代理 Webman
部署到服务器时,若使用 **Nginx** 作为站点入口,需将请求转发到本机 **Webman** 进程(默认监听端口与 `config/process.php` 中 `listen` 一致,一般为 `8787`,反代目标使用 `127.0.0.1:8787`)。
在站点 **`server { }`** 块中可增加如下写法:**先由 Nginx 根据 `root` 判断是否存在对应静态文件;不存在则转发到 Webman**`root` 建议指向项目 `public` 目录)。
```nginx
location ^~ / {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_http_version 1.1;
proxy_set_header Connection "";
if (!-f $request_filename) {
proxy_pass http://127.0.0.1:8787;
}
}
```
修改配置后执行 `nginx -t` 校验,再重载 Nginx并确保 Webman 已启动(如 `php start.php start -d`)。
若前端与接口为**不同域名**(跨域),除反代外还需保证 **HTTPS 证书与域名一致**,以及后端 **CORS / 预检OPTIONS** 与前端请求头(如 `think-lang`、`server` 等)配置一致,否则浏览器会报跨域相关错误。
---
## 六、路由说明
- **后台 API**`/admin/{module}.{Controller}/{action}`
- 示例:`/admin/mall.Player/index` → `app\admin\controller\mall\Player::index`
- 示例:`/admin/mall.Player/index` → `app\admin\controller\mall\Player::index`
- **前台 API**`/api/...`
- **安装**`/api/Install/...`