IIS 6 下配置以 FastCGI 跑 PHP

时间:2022-04-23
本文章向大家介绍IIS 6 下配置以 FastCGI 跑 PHP,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

环境: 操作系统:Windows 2003 Server SP2 PHP 版本:php-5.2.6-Win32

1.下载 FastCGI For IIS6

http://www.iis.net/download/fastcgi

下载之后,双击运行进行安装。

安装后在 C:WINDOWSsystem32inetsrv 目录下产生了五个文件。如下图:

  1. fcgiext.dll – fastcgi处理程序
  2. fcgiext.ini – 配置文件
  3. fcgiconfig.js – FastCGI的控制脚本

同时在 IIS 的 “Web 服务扩展”里多了 FastCGI Handler。

2.下载 PHP5.2.14 Windows 版

http://www.php.net/downloads.php

下载 .zip 格式的版本,下载后解压至 c:PHP 目录,并给 IIS 启动帐户组或用户赋予读取和运行权限。如下图:

你可以根据自己的意愿解压到别的目录。

3. 注册 PHP 到 FastCGI

打开 C:WINDOWSsystem32inetsrvfcgiext.ini 文件。

; This is the configuration file for the FastCGI handler for IIS 6.0.    
; The FastCGI handler will look for this file in the same directory as     
; fcgiext.dll. By default, the FastCGI installer will place this file into     
; the %windir%system32inetsrv directory.

我个人的理解是,只要“Web 服务扩展”里的 FastCGI Handler 为允许时,在加载 fcgiext.dll 时,会读取 fcgiext.ini 配置文件的内容,根据里面的配置为每个网站提供映射。

在 [Types] 下添加以下配置:

[Types]    
php=PHP
[PHP]    
ExePath=C:PHPphp-5.2.14-Win32php-cgi.exe

“php”表示扩展名,“PHP”是配置节名称,以“[PHP]”定义。

4. 配置 php.ini

将 C:PHPphp-5.2.14-Win32php.ini-recommended 复制一个,然后重命名为 D:PHPphp.ini

打开 C:PHPphp-5.2.14-Win32php.ini,修改:

extension_dir = "C:PHPphp-5.2.14-Win32ext"    
fastcgi.impersonate = 1

其它的根据实际需要对 php.ini 进行设置修改,这里只针对能跑 php,修改完记得重启 IIS。

5. 配置网站

右键网站 => 属性 => 主目录 => 配置 => 添加,如下图配置:

可执行文件路径:C:WINDOWSsystem32inetsrvfcgiext.dll

6. 写个 php 测试下吧

<?php    
phpinfo();     
?>

看到类似以下效果说明你的服务器可以跑 php 了。

打开后如果出现提示:No input file specified. 估计是没配置 fastcgi.impersonate

参考  http://hi.baidu.com/imdao/blog/item/16583512f11cb654f819b858.html

Configure the FastCGI Extension for IIS 6.0