码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2017-05-13 23:20:22      阅读:310      评论:0      收藏:0      [点我收藏+]

标签:turn   inf   http   cal   color   res   sam   gateway   tar   

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.

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

标签:turn   inf   http   cal   color   res   sam   gateway   tar   

原文地址:http://www.cnblogs.com/ch459742906/p/6850660.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!