CGI,FastCGI,PHP-CGI,PHP-FPM,Spawn-FCGI

CGI

  • CGI, Common Gateway Interface, is a tool for HTTP server to contact with programs on other servers, which can be used into any languages with standard input, standard output and environmental variables, such as PHP, Perl, or Tcl.

FastCGI

  • FastCGI is a kind of CGI which is long-live, which will always be running. With FastCGI, it‘ll take less time t fork(which is a problem of fork-and-execute mode in CGI). In additional, FastCGI also supports for distributed computing.
  • It is also not language related, which is an opened extension of CGI, which is used to keep CGI running in the memory. It‘s well-known that loading of CGI has been the main reason of low performance.
  • the main process of running FastCGI:
    1. Loading the Process Manager of FastCGI when a Web server has booted(IIS ISAPI or Apache Module)
    2. The Process Manager of FastCGI will initiate itself to create several CGI processes, which are used to wait for connection of Web servers.
    3. When requests from clients have reached the Web server, the Process Manager of FastCGI will select a CGI set up before to connect, whose environmental variables and standard input will be sent to the sub process php-cgi of FastCGI.
    4. This sub process will return standard output and error info to the Web server with the same connection. Requests will be finished when it closes the connection.
  • Therefore, FastCGI only set once for parsing php.ini, loading extensions and initiating all the data structures.

shortcuts

  • Because of multi-processes, FastCGI will cost more memory than CGI, whose each process(PHP-CGI) will cost about 7Mb to 25Mb memory.

PHP-CGI

  • PHP-CGI is one kind of the Process Manager of FastCGI, which is within php itself.
  • The command to boot is as follow:
php-cgi -b 127.0.0.1:9000

shortcuts

  • After changing php.ini, you should reboot PHP-CGI to make the new php.ini work.
  • When a PHP-CGI process is killed, all the PHP code will cannot run.(PHP-FPM and Spawn-FCGI do not have the same problem)

PHP-FPM(Fast-CGI Process Manager)

  • PHP-FPM is another kind of the Process Manager of FastCGI, which can be downloaded here.
  • It‘s actually a patch for PHP, which is used to integrate the Process Manager of FastCGI into PHP, which should be make into PHP before version 5.3.2(5.3.2以后已经集成于php中).
  • PHP-FPM can be used to control sub processes of PHP-CGI:
/usr/local/php/sbin/php-fpm [options]

# options
# --start:      start a fastcgi process of php
# --stop:       force to kill a fastcgi process of php
# --quit:       smooth to kill a fastcgi process of php
# --restart:    restart a fastcgi process of php
# --reload:     smooth to reload php.ini
# --logrotate:  enable log files again

Spawn-FCGI

  • Spawn-FCGI is a general kind of the Process Manager of FastCGI, which is one part of lighttpd.
时间: 2024-10-11 12:57:00

CGI,FastCGI,PHP-CGI,PHP-FPM,Spawn-FCGI的相关文章

[转] Nginx + CGI/FastCGI + C/Cpp

接着上篇<Nginx安装与使用>,本篇介绍CGI/FASTCGI的原理.及如何使用C/C++编写简单的CGI/FastCGI,最后将CGI/FASTCGI部署到nginx.内容大纲如下: 1.     CGI 1.1.     环境变量 1.2.     标准输入 2.     FastCGI 3. nginx cgi/fastcgi 3.1. nginx + fastcgi 3.1.1. spawn-fcgi 3.1.2. 编写fastcgi应用程序 3.1.3. nginx fastcgi

PHP运行模式(cgi,fast-cgi,cli, ISAPI ,web模块模式)【转载】

PHP运行模式有5钟: 1)cgi 通用网关接口(Common Gateway Interface))2)fast-cgi 常驻 (long-live) 型的 CGI3)cli  命令行运行   (Command Line Interface) 4)ISAPI模式(Windows中使用的) 5)web模块模式 (apache等web服务器运行的模块模式) 1.  CGI(Common Gateway Interface) CGI即通用网关接口(Common Gateway Interface),

Nginx + CGI/FastCGI + C/Cpp

http://www.cnblogs.com/skynet/p/4173450.html Nginx + CGI/FastCGI + C/Cpp 2014-12-19 11:05 by 吴秦, 19794 阅读, 6 评论, 收藏, 编辑 接着上篇<Nginx安装与使用>,本篇介绍CGI/FASTCGI的原理.及如何使用C/C++编写简单的CGI/FastCGI,最后将CGI/FASTCGI部署到nginx.内容大纲如下: 1.     CGI 1.1.     环境变量 1.2.     标

什么是CGI FastCGI PHP-CGI PHP-FPM Spawn-CGI?它们之间的关系

1. CGI: Common Gateway Interface外部应用程序: CGI是外部应用程序(CGI程序)与Web服务器之间的接口标准,是在CGI程序和Web服务器之间传递信息的规程.CGI规范允许Web服务器执行外部程序,并将它们的输出发送给Web浏览器.能够让用户访问某种特定动态资源(例*.cgi)时,触发web服务器,让web服务器根据CGI协议调用额外的应用程序(或进程)来执行这段动态程序,将这段动态程序格式化成html的代码再返回给web服务器.它就是让WEB服务器跟应用程序服

FastCGI和CGI运行差异知识普及

一.FastCGI是什么? FastCGI是语言无关的.可伸缩架构的CGI开放扩展,其主要行为是将CGI解释器进程保持在内存中并因此获得较高的性能. 众所周知,CGI解释器的反复加载是CGI性能低下的主要原因,如果CGI解释器保持在内存中并接受FastCGI进程管理器调度,则可以提供良好的性能.伸缩性.Fail-Over特性等. 二.FastCGI的工作原理 1)FastCGI进程管理器自身初始化,启动多个CGI解释器进程(多个php-cgi进程)并等待来自Web Server的连接.php-f

CGI,FastCGI,php-cgi,php-fpm的关系

参考自http://segmentfault.com/q/1010000000256516 首先,CGI是干嘛的?CGI是为了保证web server传递过来的数据是标准格式的,方便CGI程序的编写者. web server(比如说nginx)只是内容的分发者.比如,如果请求/index.html,那么web server会去文件系统中找到这个文件,发送给浏览器,这里分发的是静态数据.好了,如果现在请求的是/index.php,根据配置文件,nginx知道这个不是静态文件,需要去找PHP解析器来

fastcgi与cgi的区别

先讲下cgi:cgi在2000年或更早的时候用得比较多, 以前web服务器一般只处理静态的请求,如果碰到一个动态请求怎么办呢?web服务器会根据这次请求的内容,然后会fork一个新进程来运行外部c程序(或perl脚本...), 这个进程会把处理完的数据返回给web服务器,最后web服务器把内容发送给用户,刚才fork的进程也随之退出. 如果下次用户还请求改动态脚本,那么web服务器又再次fork一个新进程,周而复始的进行. 后来出现了一种更高级的方式是, web服务器可以内置perl解释器或ph

详解php的安装模式---CGI,FASTCGI,php-fpm,mod_php,mod_cgi,mod_fcgid

1. CGI CGI是通用网关接口,HTTP服务器使用这样的接口程序来和“其他程序”(比如PHP的解释器程序)通讯,这个“其他程序”可以使用任何计算机语言来编写,它通过CGI这个接口从HTTP服务器取得输入,然后把运行的结果又通过CGI这个接口交给HTTP服务器,而HTTP服务器把这个结果送给浏览器. CGI的出现让WEB从静态变为为动态,随着Web的越来越普及,很多的网站的都需要有动态的页面,以便与浏览者互交.CGI方式的缺点也越来越突出.因为HTTP要生成一个动态页面,系统就必须启动一个新的

php五大运行模式CGI,FAST-CGI,CLI,ISAPI,APACHE模式浅谈

做 php 开发的应该都知道 php 运行模式概念吧,本文将要和大家分享的是关于php目前比较常见的五大运行模式:包括cgi .fast-cgi.cli.isapi.apache模块的DLL ,下面作者就这五大运行模式做一些自己的分析,有不对的地方,还请留言指正. CGI运行模式 CGI即通用网关接口(Common Gateway Interface),它是一段程序,通俗的讲CGI就象是一座桥,把网页和WEB服务器中的执行程序连接起来,它把HTML接收的指令传递给服务器的执行程序,再把服务器执行

cgi fastcgi php-cgi php-fpm

cgi  fastcgi  php-cgi  php-fpm 详解 参考: 摘至:http://www.cnblogs.com/thinksasa/p/4497567.html 详说fastcgi,php-fpm的区别:http://segmentfault.com/q/1010000000256516 注:只为个人收藏积累用 什么是CGI.FastCGI.PHP-CGI.PHP-FPM.Spawn-FCGI?:http://www.mike.org.cn/articles/what-is-cg