航空 发表于 2010-5-9 08:08:31

参考资料PHP5.3.0篇(IIS6上安装)

PHP5.3.0篇:IIS6上安装MySQL5.1.38,PHP5.3,Zend3.3,phpMyAdmin3.2.2的完整方法
在IIS6.0下安装Fastcgi+PHP来运行PHP程序(未装alpha),终于实现手工配置 IIS 6 下以 FastCGI 跑 PHP
PS:微软提升PHP在IIS下的性能 FastCGI Extension for IIS6.0
微软已经和PHP社区共同努力了一年之久,他们终于研发出能让IIS更快地解析PHP的方法,用户们甚至不需要做基准测试就可以明显感觉到PHP解析速度加快.早在2006年,微软就和Zend等厂商一起研发Windows Server下的优化工作,IIS产品组已经公布了IIS6和7的FastCGI扩展,它能让PHP执行效率更高. PHP一直以来是IIS的尴尬,用PHP扩展的速度跟不上其它服务端(甚至还有一些致命问题例如在某内存地址报错),而PHP又比ASP.net普及得多,因此微软需要在IIS+PHP上突破市场. 微软去年底发布了ii6的fastcgi模块,可以免费下载,使用IIS6的您不妨在您的测试环境上试一下,没准会有惊喜哦! 今天将服务器上的php支持改成了fastcgi,目前运行稳定.fastcgi的iis模块可以让流行的应用框架在iis上支持fastcgi协议以提供高性能和可用性的访问服务,fastcgi面向现有的网络服务器提供高性能的cgi替代标准。具体php安装方法我记录下来,其中包括出现的错误.
1.下载 FastCGI For IIS6
fcgisetup32.msi(FastCGI Extension for IIS 6.0 x86)
下载:http://www.iis.net/extensions/FastCGI,选择: x86

http://www.igoworld.net/broadh/attachment/200910/4/98_1254641431jCih.jpg

或者直接下载:http://go.microsoft.com/?linkid=9655696

下载之后,双击运行进行安装。
(FakeCGI调试工具(备用):下载fake.zip http://blogs.iis.net/rickjames/attachment/1563148.ashx )

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

http://www.igoworld.net/broadh/attachment/200910/4/98_1254645247vJqn.jpg

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

http://www.igoworld.net/broadh/attachment/200910/4/98_12546452481g1m.jpg

2.下载 PHP5.3.0 Windows 版
由于PHP5.3的全新特效及改进,原有的isapi方式解析PHP脚本已经不被支持,PHP从5.3.0以后的版本开始使用微软的fastcgi模式,这是一个更先进的方式,运行速度更快,更稳定!
新版本的PHP5.3通过以往老方法已经不能在IIS上安装了,下载IIS下的PHP,下载地址http://windows.php.net/download/,(注意IIS下要选择VC9的版本)解压到所需目录,该目录需要给予user读取运行权限,
选择:PHP 5.3 (5.3.0)
VC9 x86 Thread Safe (2009-Jun-30 08:52:56) Zip
sha1: f049c806744855e4420844d47e051949fcf06661
下载 .zip 格式的版本,解压缩下载的 php-5.3.0-Win32-VC9-x86.zip 文件,并将其复制到:X:\Server_Core\php目录(你可以根据自己的意愿解压到别的目录。),并给 IIS 启动帐户组或用户赋予读取和运行权限。如下图:
http://www.igoworld.net/broadh/attachment/200910/4/98_12546452495C0P.jpg

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=X:\Server_Core\PHP\php-cgi.exe
这里要用:“\”不能用“/”,“php”表示扩展名,“PHP”是配置节名称,以“”定义。 (选你自己的安装的目录,下同。)

4. 配置 php.ini
将 X:\Server_Core\PHP\php.ini-development 复制一个,然后重命名为 X:\Server_Core\PHP\php.ini
找到PHP安装目录下的php.ini-development并改名为php.ini文件,找到下面

; Defines the default timezone used by the date functions
; http://php.net/date.timezone
; date.timezone =
更改为并去除前面的“;”:

; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Shanghai
如果不改以上的date.timezone可能打开网页会提示500错误
找到
; On windows:
; extension_dir = "ext"
改为
; On windows:
extension_dir = "X:\Server_Core\PHP\ext"

找到:fastcgi.impersonate = 1;这句,把前面的;去掉, fastcgi.impersonate = 1
如下图:
http://www.igoworld.net/broadh/attachment/200910/4/98_1254647773nwN4.jpg

找到:short_open_tag= Off;改为
short_open_tag= On

至于php.ini里面的extension开启方式,根据自己所需,找到:Windows Extensions 在 Windows Extensions 下方的动态模块配置中,需要打开以下模块支持:(去掉模块配置每行前面的;号即可)比如我的是
;extension=php_bz2.dll
;extension=php_curl.dll
;extension=php_dba.dll
extension=php_mbstring.dll
extension=php_exif.dll
;extension=php_fileinfo.dll
extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
extension=php_ldap.dll
;extension=php_ming.dll
;extension=php_mssql.dll
extension=php_mysql.dll
extension=php_mysqli.dll
;extension=php_oci8.dll      ; Use with Oracle 10gR2 Instant Client
;extension=php_oci8_11g.dll ; Use with Oracle 11g Instant Client
;extension=php_openssl.dll
;extension=php_pdo_firebird.dll
;extension=php_pdo_mssql.dll
;extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
;extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_phar.dll
;extension=php_pspell.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_soap.dll
;extension=php_sockets.dll
;extension=php_sqlite.dll
;extension=php_sqlite3.dll
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll
;extension=php_zip.dll
注意最后一个php_zip.dll这个在我下载下来的php5.3.0的ext内是不存在的,所以如果开启会报错误,如果实在需要这个DLL,可以从PHP5.2中拷贝过去(我的不行)
保存 php.ini 文件,并将其复制到 C:\Windows\ ,并删除 X:\Server_Core\PHP\php.ini,不删除有时IIS报500错!


5. 配置网站

打开IIS管理器,网站上点右键-属性-主目录-配置-添加,配置如下图


http://www.igoworld.net/broadh/attachment/200910/4/98_1254642310979w.jpg

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

6. 写个 php 测试下吧

修改完在IIS上或者命令提示符运行iisreset命令重启IIS服务,这步很重要!



测试是否安装成功!
建立一个网站,phpinfo.php文件内容为:
文件:phpinfo.php
<?php
phpinfo();
?>

看到类似以下效果说明你的服务器可以跑 php 了。
http://www.igoworld.net/broadh/attachment/200910/4/98_1254651324H2wp.jpg
安装过程出现小插曲,如果运行测试文件出现如下提示:
先运行X:\Server_Core\PHP\php-cgi.exe如果能进入命令窗口并只有光标,说明FastCGI能正常调用php-cgi,再找以下错误解决方法:
错误1,
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启动帐户赋予该目录的读取和运行权限.修改文件夹安全属性,问题解决.

错误2,
FastCGI Error
The FastCGI Handler was unable to process the request.
--------------------------------------------------------------------------------
Error Details:
Could not find entry for "php" on site 1960240566 in section.
Error Number: 1413 (0x80070585).
Error Description: ?TD§?÷òy?£
HTTP Error 500 - Server Error.
Internet Information Services (IIS)

即说明没有安装成功!请按照fcgiext.ini 修改配置即可!!
错误3,
----------
FastCGI Error
The FastCGI Handler was unable to process the request.
Error Details:
[*]The FastCGI process exited unexpectedly[*]Error Number: -1073741819 (0xc0000005).[*]Error Description: Unknown ErrorHTTP Error 500 - Server Error.
Internet Information Services (IIS)
--------
我的PHP目录在C盘
当时配置PHP.INI的时候就在那个安装目录编辑好,再复制到windows目录下的...
结果恰恰是C:\PHP\php.ini 这个"备份"文件的存在 干扰了FastCGI的运行,总是提示我。
把 C:\php\php.ini 删除,搞定!
随后用FakeCGI调试工具才搞定原因..
感谢FakeCGI,痛斥我的坏习惯!!!





PHP5.3.0特除配置
一,如何正确调整上传附件大小限制?
修改 php.ini (Windows 系统在 C:/Windows/system32 下)中的下面几项:
1. post_max_size =10M  
表单提交最大数据为10M.此项不是限制上传单个文件的大小,而是针对整个表单的提交数据进行限制的.
限制范围包括表单提交的所有内容.例如:发表贴子时,贴子标题,内容,附件等...
2.file_uploads = On   
是否允许上传文件,如果为OFF您将不能上传文件.
3.upload_tmp_dir = "C:\Server_Core\php\upload_tmp\"   
上传文件时系统使用的缓存目录.如果此目录所在磁盘空间不足的话您将不能上传文件.
4.upload_max_filesize =2M  
最大上传文件大小,此项针对上传文件时单个文件的大小.
与post_max_size之间的关系:
在论坛发表贴子时,您post_max_size 设为10M,而此项设成了2M,那么您只能上传最大为2M的附件,且可以同时上传5个.
修改之后一定要重启 Web 服务。
注意:很多人遇到修改php.ini后重应WEB服务后仍然不能生效.这种情况应该先确认一下所改的php.ini是不是当前PHP所使用的.
二,EXIF信息服务器配置说明:
1.在php.ini文件中找到;extension=php_exif.dll,去掉前面的分号
2.在php.ini文件中找到;extension=php_mbstring.dll,去掉前面的分号,并将此行移动到extension=php_exif.dll之前
3.找到段,把下面语句的分号去掉。
;exif.encode_unicode = ISO-8859-15
;exif.decode_unicode_motorola = UCS-2BE
;exif.decode_unicode_intel    = UCS-2LE
;exif.encode_jis =
;exif.decode_jis_motorola = JIS
;exif.decode_jis_intel    = JIS
PS:
安装版PHP的方法: http://www.xueit.com/eimg/uploadfile/uppig/20091/0911020152597.png
点击NEXT
http://www.xueit.com/eimg/uploadfile/uppig/20091/09110201517930.png
打上勾同意
http://www.xueit.com/eimg/uploadfile/uppig/20091/09110201538193.png
出现安装路径,默认路径,点击"Next"
http://www.xueit.com/eimg/uploadfile/uppig/20091/09110201627540.png
在这里选择:IIS FastCGI,再点击Next
http://www.xueit.com/eimg/uploadfile/uppig/20091/0911020178840.png
然后在模块里选上
mysql
GD2
Multibyte String
mcrypt
之后点击"Next",安装成功!  



待续:
页: [1]
查看完整版本: 参考资料PHP5.3.0篇(IIS6上安装)