PHP-fpm + nginx
一、初窥计算机网络
服务器向客服端提供服务
由此图看来, 服务器也是经过了七层OSI的。
二、试验
request: http://x_build.cc/img/home/index.html
www.conf 配置文件(php-fpm) | nginx.conf 配置文件(fast-cgi) | 文件index.html是否存在 | 浏览器返回报错 | fast-cgi是否加载并监听 | php-fpm是否解析 |
;security.limit_extensions = | location ~* .*\.(php|html)?$ | 存在 | 403 | 是 | 否 |
;security.limit_extensions = | location ~* .*\.(php|html)?$ | 不存在 | 404 | 是 | 否 |
security.limit_extensions = html | location ~* .*\.(php|html)?$ | 存在 | 200(显示文件内容) | 是 | 是 |
security.limit_extensions = html | location ~* .*\.(php|html)?$ | 不存在 | 404 | 是 | 是 |
;security.limit_extensions = | location ~* .*\.(php)?$ | 存在 | 200 | 否 | 否 |
;security.limit_extensions = | location ~* .*\.(php)?$ | 不存在 | 404 | 否(当做静态资源处理) | 否 |
security.limit_extensions = html | location ~* .*\.(php)?$ | 不存在 | 403 | 是(当做动态资源处理) | 否 |
security.limit_extensions = html | location ~* .*\.(php)?$ | 存在 | 200 | 否(当做静态资源处理) | 否 |
以上的测试结果能够表明在nginx配置 location ~ ..(php|html)?$中, php|html后缀文件都会加载nginx的fast-cgi模块, 并监听127.0.0.1:9000地址, 当请求到达127.0.0.1:9000地址时, 文件已经被加载到内存了(由table - row1 & row2能得出结论)
三、nginx与php-fpm结合的完整流程。
x_build.cc/img/home/index.html
|
|
Nginx
|
|
路由到x_build.cc/img/home/index.html
|
|
加载nginx的fast-cgi模块
|
|
fast-cgi监听127.0.0.1:9000地址
|
|
x_build.cc/img/home/index.html请求到达127.0.0.1:9000 (猜想:此时已经加载了index.html文件)
|
|
php-fpm 监听127.0.0.1:9000
|
|
php-fpm 接收到请求,启用worker进程处理请求
|
|
php-fpm 处理完请求,返回给nginx
|
|
nginx将结果通过http返回给浏览器
参考文章:https://segmentfault.com/a/119000000732235...
本作品采用《CC 协议》,转载必须注明作者和本文链接
推荐文章: