猫猫1 发表于 2015-8-16 08:46:59

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:\WINDOWS\system32\inetsrv 目录下产生了五个文件。如下图:

   
[*]fcgiext.dll – fastcgi处理程序   
[*]fcgiext.ini – 配置文件   
[*]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:\WINDOWS\system32\inetsrv\fcgiext.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%\system32\inetsrv directory.
  我个人的理解是,只要“Web 服务扩展”里的 FastCGI Handler 为允许时,在加载 fcgiext.dll 时,会读取 fcgiext.ini 配置文件的内容,根据里面的配置为每个网站提供映射。
  在 下添加以下配置:
     
php=PHP
     
ExePath=C:\PHP\php-5.2.14-Win32\php-cgi.exe
  “php”表示扩展名,“PHP”是配置节名称,以“”定义。
  4. 配置 php.ini
  将 C:\PHP\php-5.2.14-Win32\php.ini-recommended 复制一个,然后重命名为 D:\PHP\php.ini
  打开 C:\PHP\php-5.2.14-Win32\php.ini,修改:
  extension_dir = "C:\PHP\php-5.2.14-Win32\ext"   
fastcgi.impersonate = 1
  
  其它的根据实际需要对 php.ini 进行设置修改,这里只针对能跑 php,修改完记得重启 IIS。
  5. 配置网站
  右键网站 => 属性 => 主目录 => 配置 => 添加,如下图配置:
   
可执行文件路径:C:\WINDOWS\system32\inetsrv\fcgiext.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
页: [1]
查看完整版本: IIS 6 下配置以 FastCGI 跑 PHP