在IIS 5.1/6上以FastCGI方式安装 PHP

2010.03.15 12:51 | 标签: , | by laolin

=====================================
在IIS 5.1/6上以FastCGI方式安装 PHP
=====================================

最近下载了PHP 5.32版,发现竟然好象也许大概可能不支持isapi方式了,
反正在程序包中找不到php5isapi.dll文件了。
所以只好用FastCGI方式安装 PHP了。
以下是LaoLin的安装过程,记录下来以便自己查用。
——————————————————
IIS版本 winxp SP2中文版(好旧的系统啊)自带的IIS 5.1
(IIS6应该差不多吧)
——————————————————
以前LaoLin在自己的widows的IIS下安装PHP历来都是用isapi方式安装,
原因已经不记得了,反正就是习惯性就用ISAPI方式,
也许是LaoLin最初看的官方的介绍中ISAPI的相关段落比较短的原因吧。
——————————————————
1 下载 PHP php5.32 windows zip版(VC9 x86 Thread Safe )
不要EXE安装版的
http://windows.php.net/download/

2下载安装 Microsoft FastCGI Extension for IIS 5.1 and 6.0
( http://www.iis.net/extensions/fastcgi )
( http://download.microsoft.com/download/E/0/C/E0C0709A-66E5-4113-9A6C-A5F65BF6717D/fcgisetup_1.5_rtw_x86.msi )

因为现在的PHP不支持ISAPI方式安装了,只能fastCGI方式安装了,所以需要这个东东。

3
由于我的UE关联了js扩展名,在UE设置里取消之。
否则后面会出现“没有文件扩展“.js”的脚本引擎。”的错误
在资源管理器里简单改js扩展名的打开方式为C:\WINDOWS\system32\wscript.exe是不行的。

4
设置PHPRC环境变量改到新PHP安装的目录,比如 d:\bin0\php532
path变量后增加新的目录(这个可能不需要)

5 php.ini修改等PHP安装步骤:
php.ini还是应该放在PHP安装目录比较干净,就是前面设置的PHPRC的目录里
比如d:\bin0\php532\hp.ini
php.ini修改设置:
参考1 http://cn.php.net/manual/de/install.windows.manual.php
参考2 http://cn.php.net/manual/de/install.windows.iis6.php
fastcgi.impersonate = 1
fastcgi.logging = 0
cgi.fix_pathinfo=1
cgi.force_redirect = 0
extension_dir = - The extension_dir needs to point to the directory where PHP extensions files are stored. The path can be absolute (i.e. “C:\PHP\ext”) or relative (i.e. “.\ext”). Extensions that are listed lower in the php.ini file need to be located in the extension_dir.
extension = xxxxx.dll
- For each extension you wish to enable, you need a corresponding “extension=” directive that tells PHP which extensions in the extension_dir to load at startup time.
log_errors = On
- PHP has an error logging facility that can be used to send errors to a file, or to a service (i.e. syslog) and works in conjunction with the error_log directive below. When running under IIS, the log_errors should be enabled, with a valid error_log.
error_log = - The error_log needs to specify the absolute, or relative path to the file where PHP errors should be logged. This file needs to be writable for the web server. The most common places for this file are in various TEMP directories, for example “C:\inetpub\temp\php-errors.log”.

6 按官方说明运行命令设置fast-CGI:
cscript %windir%\system32\inetsrv\fcgiconfig.js -add -section:”PHP” ^
-extension:php -path:”d:\bin0\PHP532\php-cgi.exe”

结果总是提示已经存在旧的键值,什么的出错信息,
可能是由于我前面的其他操作引起的注册表里已经有相关的键值的原因吧。
但是我直接改注册表删相应的项也不能消除此出错信息
换fcgiconfig.js 的别的参数也消不掉此出错信息。

7 于是在网上找到手工设置法:
( 参考:http://hi.baidu.com/usen68/blog/item/8a3a4c111df6f718b8127b45.html )
右击“网站”选择“属性”,
单击“主目录”选项,点击“配置”按钮,
单击”添加“按钮,
单击”浏览“ 在 %WINDIR%\system32\inetsrv 里寻找fcgiext.dll 。
在扩展名里输入 .php ,
动作选择”限制为“,输入”GET,HEAD,POST“。
确认”脚本引擎“和”检查文件是否存在“是否选择,
如没选中,请选中。
确认无误后,单击”确定“。
配置fcigext.ini (温馨提示:它在%WINDIR%\system32\inetsrv 目录里)
简单的在fcigext.ini 末尾添加如下内容即可:
[Types]
php=PHP
[PHP]
ExePath=c:\php\php-cgi.exe
修改好fcigext.ini
我是运行一下cscript %windir%\system32\inetsrv\fcgiconfig.js -syncini
然后重启IIS,运行上行的命令好处是可以看自己手工改的INI文件有没有写错。
上述参考网页说是直接重启IIS就行了。

8
打开phpinfo页面,终于出来了,和原来的ISAPI的不同
表格第五行可以看到是CGI/FastCGI:
Server API CGI/FastCGI

后面PHP扩展的设置包括mysql和以前ISAPI一样就不记录了。

目前还没有任何评论.