Install PHP to IIS (FastCGI)

Install PHP to IIS8.5

1、安装Visual C++ Redistributable for Visual Studio 2012 Update 4(x86)
2. 解压php-xxx-nts-x86 / x64-VC11.zip文件
3.打开C:\php
复制php.ini-production为php.ini
用记事本打开php.ini
做如下修改:
; to fastcgi
cgi.force_redirect=0
cgi.fix_pathinfo=1
fastcgi.impersonate=1
cgi.rfc2616_headers=1
;date.timezone = PRC
;date.timezone =Etc/GMT+8
date.timezone =Asia/Shanghai
short_open_tag = Off
expose_php = Off

upload_tmp_dir = D:\wwwtemp
max_file_uploads = 20
upload_max_filesize = 20M

以下php扩展模块,根据需要选择开启,取消前面的分号为开始相应扩展模块
extension=php_curl.dll
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_exif.dll
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_sockets.dll
extension=php_xmlrpc.dll
extension=php_pdo_mysql.dll

4、配置IIS支持PHP (Fast CGI php)
(1) IIS-计算机名称
打开“处理程序映射”
“添加模块映射”
请求路径:*.php模块:FastCgiModule
可执行文件(可选):C:\php\php-cgi.exe
名称:FastCGI

(2)打开“FastCGI设置”,可选,根据实际需要配置 或 使用默认

测试 http://localhost:xxx/phpinfo

Install FastCGI to IIS6
1. download

http://www.iis.net/expand/FastCGI

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

安装后在 C:\WINDOWS\system32\inetsrv 目录下产生了五个文件。

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

 

2. 下载PHP5.3.2 Windows
http://windows.php.net/download/

下载 .zip 格式的版本,下载后解压至 D:\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 配置文件的内容,根据里面的配置为每个网站提供映射。

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

[Types]
php=PHP

[PHP]
ExePath=D:\PHP\php-cgi.exe

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

 

4. 配置php.ini

将 D:\PHP\php.ini-recommended 复制一个,然后重命名为 D:\PHP\php.ini

打开 D:\PHP\php.ini,修改:

extension_dir = “D:\PHP\ext”
fastcgi.impersonate = 1

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

5. 配置网站

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

在可执行文件路径:C:\WINDOWS\system32\inetsrv\fcgiext.dll

然后文件扩展名写:PHP

6. 写个php 测试下吧

<?php
phpinfo();
?>

看到PHP的信息的话就说明你的服务器可以跑 php 了。

打开后如果出现提示:

No input file specified.

估计是没配置 fastcgi.impersonate。

如果你还觉得麻烦,那就到 http://www.zend.com 下载 Zend Core,这个就什么都不用配置,安装完就可以使用了,连 MySQL 都有。

微软去年底发布了II6的FastCGI模块,今天将服务器上的PHP支持改成了FastCGI,目前运行稳定.FastCGI的IIS模块可以让流行的应用框架在IIS上支持FastCGI协议以提供高性能和可用性的访问服务,FastCGI面向现有的网络服务器提供高性能的CGI替代标准。具体PHP安装方法我记录下来,其中包括出现的一个错误.

环境:
操作系统:Windows 2003 Server
PHP版本:PHP5.25

1.下载FastCGI For IIS6
http://www.microsoft.com/downloads/details.aspx?FamilyID=2d481579-9a7c-4632-b6e6-dee9097f9dc5&displaylang=en

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

2.下载PHP5.25 Windows版
http://www.php.net

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

3.注册PHP到FastCGI
在命令行下运行
cscript fcgiconfig.js -add -section:"PHP" -extension:php -path:"D:\PHP\php-cgi.exe"

fcgiconfig.js 默认存放目录是:C:\WINDOWS\system32\inetsrv

4.设置
将D:\PHP\php.ini-recommended重命名为为D:\PHP\php.ini
打开D:\PHP\php.ini,修改:
extension_dir = "D:\PHP\ext"
fastcgi.impersonate = 1
cgi.fix_pathinfo=1
cgi.force_redirect = 0

其它根据实际需要对php.ini进行设置修改
然后执行:
cscript fcgiconfig.js -set -section:"PHP" -InstanceMaxRequests:500
cscript fcgiconfig.js -set -section:"PHP" -EnvironmentVars:PHP_FCGI_MAX_REQUESTS:1000
以上两项设置最大池和响应连接数,可以根据运行机器的硬件配置、使用情况修改

一切完毕之后重启IIS,赶紧写一个测试页试一下吧.

我第一次安装时,由于为了服务器的安全我删除了wsshell命令,导致在第3步时出现了如下错误:
Microsoft JScript 运行时错误: Automation 服务器不能创建对象
后通过重新注册命令:regsvr32 WSHom.ocx
问题解决

 

配置 php.ini

D:\PHP\php.ini-production 复制一个,然后重命名为 D:\PHP\php.ini

打开 D:\PHP\php.ini
修改PHP.ini文件:
1
。第531行改为:display_errors = On
2
。第542行改为:display_startup_errors = On
3
。第624行改为:error_prepend_string = "<br><font color=#ff0000>"
4
。第630行改为:error_append_string = "</font><br><br>"
5
。第813行改为:extension_dir = "D:\php\php_setup_files\php-5.3-vc9\ext\"
6
。第854行改为:fastcgi.impersonate = 1
7
。从948行到988行根据自己的需要修改
8
。第997行改为:date.timezone = asia/Shanghai

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

 

重启IIS后,打开测试页出现如下提示:

FastCGI Error
The FastCGI Handler was unable to process the request.
--------------------------------------------------------------------------------

Error Details:

Error Number: 5 (0x80070005).
Error Description: 拒绝访问。
HTTP Error 500 - Server Error.
Internet Information Services (IIS)

这个错误是由于在解压PHP之后,没有对IIS启动帐户赋予该目录的读取和运行权限.修改文件夹安全属性,问题解决.

----------------------------------------------------------------------------------

错误信息:
1
Error Number: 14001 (0x800736b1).
没有安装Microsoft Visual C++ 2008 Redistributable Package

下载地址:http://www.microsoft.com/downloads/details.aspx?familyid=9B2DA534-3E03-4391-8A4D-074B9F2BC1BF&displaylang=zh-cn
2
Error Number: 5 (0x80070005).
Unable to place a FastCGI process in a JobObject. Try disable the Application Pool CPU Limit feature
取消CPU的监视

3。No input file specified.

估计是没配置 fastcgi.impersonate

 

此条目发表在web server分类目录,贴了, 标签。将固定链接加入收藏夹。