拍黄片运行模式

时间:2025-02-18 09:42:47

(1)、Web Server启动时载入FastCGI进程管理器【PHP的FastCGI进程管理器是PHP-FPM(php-FastCGI Process Manager)】(IIS ISAPI或Apache Module);

(2)、FastCGI进程管理器自身初始化,启动多个CGI解释器进程 (在任务管理器中可见多个)并等待来自Web Server的连接。

(3)、当客户端请求到达Web Server时,FastCGI进程管理器选择并连接到一个CGI解释器。Web server将CGI环境变量和标准输入发送到FastCGI子进程php-cgi。

(4)、FastCGI子进程完成处理后将标准输出和错误信息从同一连接返回Web Server。当FastCGI子进程关闭连接时,请求便告处理完成。FastCGI子进程接着等待并处理来自FastCGI进程管理器(运行在 WebServer中)的下一个连接。在正常的CGI模式中,在此便退出了。

在CGI模式中,你可以想象 CGI通常有多慢。每一个Web请求PHP都必须重新解析、重新载入全部dll扩展并重初始化全部数据结构。使用FastCGI,所有这些都只在进程启动时发生一次。一个额外的好处是,持续数据库连接(Persistent database connection)可以工作。


Fastcgi的优点:

1)从稳定性上看, fastcgi是以独立的进程池运行来cgi,单独一个进程死掉,系统可以很轻易的丢弃,然后重新分 配新的进程来运行逻辑.

2)从安全性上看,Fastcgi支持分布式运算. fastcgi和宿主的server完全独立, fastcgi怎么down也不会把server搞垮.

3)从性能上看, fastcgi把动态逻辑的处理从server中分离出来, 大负荷的IO处理还是留给宿主server, 这样宿主server可以一心一意作IO,对于一个普通的动态网页来说, 逻辑处理可能只有一小部分, 大量的图片等静态 

FastCGI缺点说完了好处,也来说说缺点。从我的实际使用来看,用FastCGI模式更适合生产环境的服务器。但对于开发用机器来说就不太合适。因为当使用 Zend Studio调试程序时,由于 FastCGI会认为 PHP进程超时,从而在页面返回 500错误。这一点让人非常恼火,所以我在开发机器上还是换回了 ISAPI模式。

安装fastcgi模式:

安装apache路径是/usr/local/httpd/
安装php路径是/usr/local/php/
1)安装mod_fastcgi
wget /dist/mod_fastcgi-2.4.
tar zxvf mod_fastcgi-2.4.
cd mod_fastcgi-2.4.6
cp Makefile.AP2 Makefile
vi Makefile,编辑top_dir = /usr/local/httpd
make
make install
安装完后,
/usr/local/httpd/modules/多出一个文件:mod_fcgid.so
2)重新编译php
./configure --prefix=/usr/local/php --enable-fastcgi --enable-force-cgi-redirect --disable-cli
make 
make install
这样编译后,在PHP的bin目录下的php-cgi就是fastcgi模式的php解释器了
安装成功后,执行
php -v 输出
PHP 5.3.2 (cgi-fcgi).
这里输出带了cgi-fcgi
注意:
1. 编译参数不能加 –with-apxs=/usr/local/httpd/bin/apxs 否则安装出来的php执行文件是cli模式的
2  如果编译时不加--disable-cli则输出  PHP 5.3.2(cli)
 
3)配置apache
需要配置apache来以fastcgi模式运行php程序
vi
我们使用虚拟机的方式实现:

#加载fastcgi模块
LoadModule fastcgi_module     modules/mod_fastcgi.so
#//以静态方式执行fastcgi 启动了10进程
FastCgiServer /usr/local/php/bin/php-cgi  -processes 10 -idle-timeout 150 -pass-header HTTP_AUTHORIZATION
<VirtualHost *:80>
     #
     DocumentRoot   /usr/local/httpd/fcgi-bin   
     ServerName
     
     ScriptAlias /fcgi-bin/   /usr/local/php/bin/   #定义目录映射 /fcgi-bin/ 代替 /usr/local/php/bin/
     Options +ExecCGI
     AddHandler fastcgi-script .php .fcgi         #.php结尾的请求都要用php-fastcgi来处理  
     AddType application/x-httpd-php .php     #增加MIME类型
     Action application/x-httpd-php /fcgi-bin/php-cgi  #设置php-fastcgi的处理器: /usr/local/php/bin/php-cgi

 <Directory /usr/local/httpd/fcgi-bin/>
      Options Indexes ExecCGI
      Order allow,deny
      allow from all
 </Directory>
</VirtualHost>

或者
<IfModule mod_fastcgi> ScriptAlias /fcgi-bin/ "/usr/local/php/bin" #定义目录映射 FastCgiServer /usr/local/php/bin/php-cgi   -processes 10 #配置fastcgi server, <Directory "/usr/local/httpd/fcgi-bin/"> SetHandler fastcgi-script Options FollowSymLinks Order allow,deny Allow from all </Directory> AddType application/x-httpd-php .php&nbsp; #增加MIME类型 AddHandler php-fastcgi .php   #.php结尾的请求都要用php-fastcgi来处理 Action php-fastcgi /fcgi-bin/php-cgi #设置php-fastcgi的处理器

</IfModule>


4).restart 下apache,查看phpinfo,如果服务器信息是:
Apache/2.2.11 (Unix) mod_fastcgi/2.4.6之类的就说明安装成功了。
如果出现403的错误,查看下/usr/local/httpd/fcgi-bin/是否有足够的权限。
或者
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>
改为:
<Directory />
    Options FollowSymLinks
    AllowOverride None
Order allow,deny
Allow from all
</Directory>
就可以了。
ps -ef|grep  php-cgi可以看见10个fastcgi进程在跑。