[IIS7] FastCGI PHP on Windows Server 2003
微软近来对 PHP 的支持尤为突出,最近才发布的 Expression Studio 2 中的 Expression Web 2 就直接提供了对 PHP 的支持,而早些时候发布的 FastCGI RTM ,使 PHP 在 Windows 的 IIS 平台上的执行效率大大提高,并且内置在了 Windows Server 2008 中。新加坡一家公司曾经测试在 Windows 的 IIS 平台上运行 PHP,执行效率足足提高了 130% 以上,这是一个惊人的数字。
FastCGI 除了支持 Windows Server 2008 还支持 Windows Server 2003,下面是 FastCGI 的原文介绍:
Overview
The FastCGI Extension for IIS 6.0 enables popular application frameworks that support FastCGI protocol to be hosted on the IIS web server in a high-performance and reliable way. FastCGI provides a high-performance alternative to the Common Gateway Interface (CGI), a standard way of interfacing external applications with Web servers that has been supported as part of the IIS feature-set since the very first release.
CGI programs are executables launched by the web server for each request in order to process the request and generate dynamic responses that are sent back to the client. Because many of these frameworks do not support multi-threaded execution, CGI enables them to execute reliably on IIS by executing exactly one request per process. Unfortunately, it provides poor performance due to the high cost of starting and shutting down a process for each request.
FastCGI addresses the performance issues inherent to CGI by providing a mechanism to reuse a single process over and over again for many requests. Additionally, FastCGI maintains compatibility with non-thread-safe libraries by providing a pool of reusable processes and ensuring that each process will only handle one request at a time.
For additional support information, go to http://support.microsoft.com.
Features
The Microsoft FastCGI Extension for IIS provides full support for hosting and executing FastCGI enabled applications on IIS in high performance and reliable way.
Some of the important features provided in this release of FastCGI Extension are listed below:
Reliable hosting of non thread-safe applications (such as PHP) in FastCGI mode by enforcing single request concurrency per FastCGI process
Support for hosting of FastCGI application frameworks on shared servers by providing necessary configurability.
Rich set of configuration options for tweaking performance of FastCGI extension and FastCGI processes.
The following list describes the most important changes since the Go Live release:
Changes to fcgiext.ini take effect without restarting web service process
When any configuration change is made to fcgiext.ini file the change is picked up by the FastCGI Extension right away, without any need to restart the Web Server process. Because of that it is recommended to use the configuration script (fcgiconfig.js) included in this release instead of the one provided with Go Live release. The configuration script that was included with Go Live release recycled the application pool or restarted the web service every time a configuration change was made. It is not necessary to perform these operations anymore, so the application pool recycling functionality has been removed from the configuration script.
RapidFailsPerMinute configuration setting can be used to control Rapid Failure Protection mode
By default the FastCGI extension goes into Rapid Failure Protection mode, if it encounters more than 10 failures per minute in the FastCGI process pool. The RapidFailsPerMinute setting can be used to specify the number of failures per minute that would trigger Rapid Failure Protection mode.
Configuration script (fcgiconfig.js) can re-create IIS script mappings from fcgiext.ini file
The new command “-syncini” has been added to fcgiconfig.js to allow for re-creation of IIS script mappings by using FastCGI process pool configuration information available in the fcgiext.ini file. For example this command can be used in situations when the FastCGI extension is un-installed and then re-installed, since all script mappings are removed during un-install.
The following bugs have been fixed since Go Live release:
Responses with empty header values caused the FastCGI extension to fail response processing
The status codes logged by the FastCGI extension may be different from what was sent to the client
On 64 bit machines with Enable32BitAppOnWin64 set, fcgiext.dll would look for configuration in windowssyswow64inetsrv instead of windowssystem32inetsrv
Stability under heavy load has been improved
Benefits
Most applications built to for IIS take advantage of the native, multi-threaded extensibility model of IIS. Many popular applications, particularly those written or originally designed for Linux, are not multi-threaded, and instead take a multi-process approach to concurrency. While the PHP engine itself is multi-thread capable, many of the popular PHP extensions are not, requiring a single concurrent request guarantee to operate reliably. This forces the use of CGI and results in poor performance on the Windows platform. FastCGI helps these application frameworks to achieve improved performance on Windows over CGI, while allowing stable operation in production environments.
Requirements
To use FastCGI extension, you must have one of the following operating systems with IIS installed:
Windows Server 2003 SP2 (IIS 6.0)
Windows Server 2003 x64 edition (IIS6.0)
下载地址:FastCGI Extension for Internet Information Services 6.0
上述介绍原文地址:FastCGI Extension for IIS6.0 - RTM
FastCGI 在 Windows Server 2003 上的安装非常简单,一路 Next 即可完成。而今天的主题则是与大家分享在 Windows Server 2003 上配置 PHP 的 FastCGI 模式。与以往的 PHP 常规配置不同,PHP 使用 FastCGI 来解释脚本,所以我们将会使用 fcgiext.dll 来解释 PHP,之后我们便需要编写 FastCGI 的配置文件(FCGIEXT.ini)使 PHP 与之集成。具体操作步骤如下:
1. 运行 Inetmgr.exe 启动 IIS 管理器;
2. 进入“网站”属性(如果只希望为某个站点启用 FastCGI PHP 支持,则需要单独配置该站点);
3. 切换到“主目录”配置页,并单击“配置”进入“应用程序配置”;
4. 在“影射”配置下单击“添加”创建一个应用程序扩展;
5. 在“可执行文件”中键入用于解释 PHP 脚本的 FastCGI 地址:“C:WINDOWSsystem32inetsrvfcgiext.dll”,“限制为”指定只允许“GET,HEAD,POST”。
至此就完成了应用程序影射的添加。
之后,编辑 PHP.ini 文件,配置如下参数:
1. fastcgi.impersonate = 1
2. cgi.fix_pathinfo = 1
3. cgi.force_redirect = 0
完成后,将 PHP.ini 拷贝到 Windows 目录,或者在之后的 FCGIEXT.ini 配置 PHP.ini 的位置。
最后,编辑 FCGIEXT.ini 文件,在“[Types]”字段下添加如下内容:
php=c:\php\php-cgi.exe
Arguments=-c c:\windows\php.ini
至此就完成了整个配置,我们可以编写一个 PHP 测试脚本,内容如下:
<? phpinfo (); ?>
打开浏览器来测试一下吧!
[PHP] Cookie 验证方式的 phpMyadmin 配置文件
文件名:config.inc.php
<?php
/* Server localhost (cookie) [1] */
$i++;
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* End of servers configuration */
?>
收到 2008 微软最有价值专家(MVP) 大礼包
2008 微软最有价值大礼包是跟手表同一天到的,微软通过 DHL 递送,这次 DHL 的效率很高,远远快于 UPS。2008 的礼包有很大的变化,除了包装盒和礼品的变化外 MVP Logo 胸牌、MVP ID卡片、MVP 证书都重新经过设计!很漂亮!
礼品方面则改为了蓝牙套装:蓝牙耳机、卡片式蓝牙鼠标、蓝牙适配器。其中蓝牙耳机我到今天为止仍然没有调试成功,配对后声音无法传递过来,让我很是郁闷。
除了蓝牙耳机而配套一个蓝牙音频发射器,可以在没有蓝牙的设备上使用,如:MP3、收音机、录音机等等。只可惜本人愚钝,到目前为止都没能在笔记本和掌上电脑上使用成功。唉!
Mogo Mouse BT
这个 Mogo Mouse BT(卡片式蓝牙鼠标)确实不错,虽然与传统鼠标的性能无法媲美,但是它确实非常便于携带,而且内置充电电池,充电时只需要将鼠标插入到笔记本的 PC 卡插槽中即可,当然这里也就是存放鼠标的地方。使用时只需要打开托架鼠标便会自动开启就可以使用了。
礼品盒之前已经收起来了,也懒得再拿出来拍照 Show 一下,呵呵!