FastCGI 协议分析与C语言实现实例
来源:互联网 发布:noogenesis数据bi平台 编辑:程序博客网 时间:2024/05/19 17:57
考虑让我的 web server 增加对 PHP 的支持,这就要用到 php 解析器来将客户端请求的 php 文件解析为静态资源,再由我的 web server 将其返回到客户端,php-fpm 就可以来帮我们完成这个工作。可是我的 web server 如何与 php-fpm 通信呢? 接下来就是本文的主角:FastCGI 。
FastCGI 实现与测试代码:https://github.com/Tanswer/FastCGI
Web Server 项目地址:https://github.com/Tanswer/Xserver
Description
C language through FastCGI protocol, through php-fpm, php file parsed into html files.
How to use
Preparation:
please make sure you have installed php-fpm.
Testing environment:CentOS 7
configuration file:/usr/local/php/etc/php-fpm.conf
php file:my own user home directory —/home/Tanswer/index.php
If you want to run, you need to change the php file path of main.c.
Modify the configuration
After the installation is complete, the default communication method for unix local domain socket communication, our example and php-fpm for TCP communication, so we should change the configuration, the ip address is set to 127.0.0.1, listening port 9000. As follows:
restart php-fpm
sudo service php-fpm restart
compiling and running
git clone git@github.com:Tanswer/FastCGI.gitcd FastCGI && make./main
found an error after running:
error:Unable to open primary script: /home/Tanswer/index.php (No such file or directory)
This is the issue of permissions, the permissions of index.php are:
-rw-r--r-- 1 Tanswer Tanswer 64 12月 23 13:16 index.php
. From the above default configuration file can be seen, the account that started the php-fpm process is www, and here we change it to Tanswer,as follows:run again
./main
, the result is as follows:
Reference material
- fastcgi协议分析与实例
- php-fpm - 启动参数及重要配置详解
- FastCGI
博主着重关心如何使用,对协议的细节描述的不是很清楚,请自行查询相关资料。
- FastCGI 协议分析与C语言实现实例
- fastcgi协议分析与实例
- fastcgi协议分析与实例
- fastcgi协议分析与实例
- C语言实现CRC算法实例分析
- fastcgi协议分析
- FastCGI协议分析
- HTTP协议的C语言编程实现实例
- HTTP协议的C语言编程实现实例
- HTTP协议的C语言编程实现实例
- [ZT]HTTP协议的C语言编程实现实例
- HTTP协议的C语言编程实现实例
- HTTP协议的C语言编程实现实例
- HTTP协议的C语言编程实现实例
- HTTP协议的C语言编程实现实例[摘抄]
- HTTP协议的C语言编程实现实例
- HTTP协议的C语言编程实现实例
- HTTP协议的C语言编程实现实例
- 视频编码之I帧 、P帧、B帧
- 宿舍里的故事之五子棋
- Mac 下启动tomcat
- 廉价16bit音频DAC芯片TM8211(PT8211、TDA1311)
- HttpClient 连接池的简单实现
- FastCGI 协议分析与C语言实现实例
- SSL_1010 方格取数
- elementUI table的滑动条
- 关于libjpeg或libjpeg-turbo使用中的一个注意事项
- mybatis和mysql中查询前六个月订单中每个月的总订单数
- shell脚本-计算1到100的和
- 整理一下Unity界面的知识
- 小草软路由-多网卡普通路由模式设置
- 线程中的同步和异步的区别