PHP-fpm + nginx

一、初窥计算机网络
file

服务器向客服端提供服务

由此图看来, 服务器也是经过了七层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 协议》,转载必须注明作者和本文链接
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!
文章
1
粉丝
0
喜欢
3
收藏
0
排名:1070
访问:4849
私信
所有博文
社区赞助商