webman后台
This commit is contained in:
157
docs/webman部署说明.md
Normal file
157
docs/webman部署说明.md
Normal file
@@ -0,0 +1,157 @@
|
||||
# Webman 部署说明(步骤 11)
|
||||
|
||||
> 对应迁移文档「步骤 11:入口与部署」
|
||||
|
||||
---
|
||||
|
||||
## 一、入口与启动
|
||||
|
||||
Webman **不使用** `public/index.php` 作为入口,而是通过命令行启动常驻进程:
|
||||
|
||||
```bash
|
||||
# 进入项目目录
|
||||
cd dafuweng-webman
|
||||
|
||||
# 启动(默认监听 8787 端口)
|
||||
php start.php start
|
||||
|
||||
# 后台运行(daemon 模式)
|
||||
php start.php start -d
|
||||
|
||||
# 停止
|
||||
php start.php stop
|
||||
|
||||
# 重启
|
||||
php start.php restart
|
||||
```
|
||||
|
||||
- 入口脚本:`start.php`(项目根目录)
|
||||
- 默认端口:**8787**(在 `config/process.php` 中配置)
|
||||
- 修改端口:编辑 `config/process.php` 中 `listen => 'http://0.0.0.0:8787'`
|
||||
|
||||
---
|
||||
|
||||
## 二、public 目录静态资源
|
||||
|
||||
`public/` 目录需保留以下内容,供 Nginx 直接提供或前端引用:
|
||||
|
||||
| 路径 | 说明 |
|
||||
|------|------|
|
||||
| `install/` | 安装向导(index.html、assets 等) |
|
||||
| `robots.txt` | 搜索引擎爬虫规则 |
|
||||
| `favicon.ico` | 站点图标(可选) |
|
||||
| `index.html` | 前端 SPA 入口(若已编译) |
|
||||
|
||||
**说明**:`index.php`、`router.php` 为 ThinkPHP 入口,Webman 不需要,无需复制。
|
||||
|
||||
---
|
||||
|
||||
## 三、Nginx 反向代理
|
||||
|
||||
将 Nginx 的 `root` 指向 Webman 的 **public** 目录,动态请求代理到 8787 端口。
|
||||
|
||||
### 配置示例
|
||||
|
||||
```nginx
|
||||
upstream webman {
|
||||
server 127.0.0.1:8787;
|
||||
keepalive 10240;
|
||||
}
|
||||
|
||||
server {
|
||||
server_name 你的域名;
|
||||
listen 80;
|
||||
access_log off;
|
||||
# 必须指向 webman 的 public 目录,不能是项目根目录
|
||||
root /path/to/dafuweng-webman/public;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ @proxy;
|
||||
}
|
||||
|
||||
location @proxy {
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
proxy_pass http://webman;
|
||||
}
|
||||
|
||||
# 拒绝访问 .php 文件(Webman 无 PHP 入口)
|
||||
location ~ \.php$ {
|
||||
return 404;
|
||||
}
|
||||
|
||||
# 允许 .well-known(如 Let's Encrypt)
|
||||
location ~ ^/\.well-known/ {
|
||||
allow all;
|
||||
}
|
||||
|
||||
# 拒绝隐藏文件/目录
|
||||
location ~ /\. {
|
||||
return 404;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 配置要点
|
||||
|
||||
- **root**:必须为 `dafuweng-webman/public`,否则可能暴露配置等敏感文件
|
||||
- **try_files**:先查找静态文件,找不到再代理到 Webman
|
||||
- **proxy_pass**:指向 `http://webman`(upstream 8787)
|
||||
|
||||
### HTTPS 示例
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name 你的域名;
|
||||
root /path/to/dafuweng-webman/public;
|
||||
|
||||
ssl_certificate /path/to/cert.pem;
|
||||
ssl_certificate_key /path/to/key.pem;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ @proxy;
|
||||
}
|
||||
|
||||
location @proxy {
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
proxy_pass http://webman;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 四、开发环境快速访问
|
||||
|
||||
不配置 Nginx 时,可直接访问:
|
||||
|
||||
- 接口:`http://127.0.0.1:8787/api/xxx`、`http://127.0.0.1:8787/admin/xxx`
|
||||
- 静态:`http://127.0.0.1:8787/install/`、`http://127.0.0.1:8787/robots.txt`
|
||||
|
||||
Webman 会从 `public/` 目录提供静态文件。
|
||||
|
||||
---
|
||||
|
||||
## 五、安装检测说明
|
||||
|
||||
原 ThinkPHP 在 `public/index.php` 中做安装检测(无 `install.lock` 时跳转 `/install/`)。
|
||||
Webman 迁移后:
|
||||
|
||||
- 若使用 Nginx:安装检测逻辑需在 **路由/中间件** 或 **前端** 中实现
|
||||
- 若直接访问 8787:可在 `app/common/middleware` 或 Api/Backend 基类中增加安装检测
|
||||
|
||||
---
|
||||
|
||||
## 六、参考
|
||||
|
||||
- [Webman 官方文档 - nginx 代理](https://workerman.net/doc/webman/others/nginx-proxy.html)
|
||||
Reference in New Issue
Block a user