# 静态文件
此页面参照了EasySwoole Distributed的文档,原文档地址
[https://www.kancloud.cn/tmtbe/goswoole/1107486](https://www.kancloud.cn/tmtbe/goswoole/1107486)
## Nginx
绝大多数情况我们需要将服务端的端口通过`nginx`绑定域名后转发到后端端口。此时将nginx 的root指定到静态文件路径如`/data/wwwroot/dist`即可。
~~~
upstream esd_server{
keepalive 2000;
ip_hash;
server 127.0.0.1:8080 max_fails=3 fail_timeout=15;
server 127.0.0.2:8080 max_fails=3 fail_timeout=15;
server 127.0.0.3:8080 backup;
}
server {
listen 80;
server_name hello.com;
client_max_body_size 20m;
root /data/wwwroot/dist;
access_log /data/wwwlogs/access.log;
error_log /data/wwwlogs/error.log notice;
if(!-e $request_filename){
proxy_pass http://esd_server;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
~~~
## 直接设置静态路径
配置文件增加如下参数,`document_root`设置为静态文件路径
~~~
esd:
server:
document_root: /data/examples/www
enable_static_handler: true
~~~
- 1 介绍
- 2 安装
- 2.1 环境
- 2.2 安装
- 3 配置
- 3.1 Server配置
- 3.2 端口配置
- 3.3 项目结构
- 3.4 内核优化
- 4 服务
- 4.1 HTTP服务
- 4.1.1 路由
- 4.1.1.1 静态路由
- 4.1.1.2 路由定义
- 4.1.1.3 路由方法
- 4.1.1.4 路由分组
- 4.1.1.5 资源路由
- 4.1.1.6 端口作用域
- 4.1.1.7 异常处理
- 4.1.1.8 跨域请求
- 4.1.1.9 路由缓存
- 4.1.2 控制器
- 4.1.2.1 控制器初始化
- 4.1.2.2 前置后置操作
- 4.1.2.3 跳转与重定向
- 4.1.2.4 异常处理
- 4.1.3 请求
- 4.1.3.1 请求对象
- 4.1.3.2 请求信息
- 4.1.3.3 REQUEST消息
- 4.1.3.4 RESPONSE消息
- 4.1.3.5 STREAM消息
- 4.1.3.6 URI信息
- 4.1.3.7 处理上传文件
- 4.1.3.8 验证器
- 4.2 Websocket服务
- 4.2.1 Websocket配置
- 4.2.2 Websocket路由
- 4.3 TCP服务
- 4.3.1 TCP配置
- 4.3.2 TCP路由
- 4.3.3 协程处理案例
- 5 插件
- 5.15 Yii-PDO插件
- 5.15.1 PDO 连接MySQL Mariadb
- 5.15.2 PDO连接PostgreSQL
- 5.15.3 PDO连接GreenPlum
- 5.15.4 PDO连接Oracle
- 5.15.5 PDO连接Cubrid
- 5.15.6 PDO连接SQL Server
- 6 概念
- 7. Yii- I18N国际化
- 8. 模型 Yii-Model
- 8.1 快速创建模型
- 8.2 快速创建多个模型
- 8.3 核心验证器 Core Validators
- 9. 配合数据库工作
- 9.1.数据库访问对象 Database Access Objects
- 9.2 查询构造器 Query Builder
- 9.3 活动记录 Active Record