windows下的IIS6+PHP5.3和apache2.2.11+PHP5.3双服务器

首先要知道的是,那个服务器平台对应PHP那个版本:
1。在windows下使用Apache+PHP的,请选择VC6版本;
2。在windows下使用IIS+PHP的,请选择VC9版本;

PHP5.3是不能在IIS6上面通过ISAPI扩展运行的,而且在PHP5.3文件里面也没有php5isapi.dll,取而代之的是php5nsapi.dll,换句话说PHP5.3以后的版本就不再用ISAPI进行扩展在IIS里运行了,那有没有什么办法让PHP5.3在IIS里运行的呢,当然有了,那就是FastCGI。据说它的效率很高的哟。(昨天晚上在IIS里配置PHP5.3,结果老不成功,虽然在windows 2003下配置过apache2.2.11+PHP5.3顺利的成功了,但没想到PHP5.3不支持ISAPI了,还被同学鄙视。晕,写下此文,留作记号)


第一部分:IIS6+PHP5.3

1.下载 FastCGI For IIS6

http://go.microsoft.com/?linkid=9707432

下载之后,双击运行进行安装。或者直接本站下载fcgisetup_1.5_rtw_x86.msi

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

 

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

 

2.下载 PHP5.3 Windows 版

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

下载 .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-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。

5. 配置网站

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

 

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

6. 写个 php 测试下吧

<?php
phpinfo();
?>


PHP目录权限:IWAM_机器名称(和上图中并没有影响,感觉它的权限更小些,但两种权限都能正常运行)


下面附上优化后的配置:

[Types]
php=PHP

[PHP]
ExePath=D:\SOFT_PHP_PACKAGE\php\php-cgi.exe
InstanceMaxRequests=300
ActivityTimeout=180
RequestTimeout=300
EnvironmentVars=PHP_FCGI_MAX_REQUESTS:1000,PHPRC:D:\SOFT_PHP_PACKAGE\php\,MonitorChangesTo=D:\SOFT_PHP_PACKAGE\php\php.ini

参数参考:
http://www.iis.net/learn/application-frameworks/running-php-applications-on-iis/configure-php-process-recycling-behavior

http://www.iis.net/learn/application-frameworks/install-and-configure-php-on-iis/configuring-the-fastcgi-extension-for-iis-60


由于此次是部署在生产环境上,所以各方面我都很小心:
上面版本全部采用no thread safe(nts),加载模块使用微软自己的:http://www.iis.net/downloads/microsoft/wincache-extension (自个选择对应的版本,在页面最下面)
extension=php_wincache.dll

在页面上打印出:print_r(wincache_fcache_fileinfo());


 




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


3。Error Number: 5 (0x80070005).
   Unable to place a FastCGI process in a JobObject. Try disable the Application Pool CPU Limit feature
   取消CPU的监视

2。No input file specified.

估计是没配置 fastcgi.impersonate。

1。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 Error

HTTP Error 500 - Server Error.
Internet Information Services (IIS)
答:可能是extension_dir = "D:/php/php-5.31-vc9/ext/" 的错误,请注意路径的写法。但还是建议安装完成后,重启一下电脑。还有版本不要选错了

 


第二部分:apache2.2.11 + php5.3
   1。下载apache2.2.11     下载网址:www.apache.org
   2。下载php5.3    下载网站:http://windows.php.net/download/  (在此选择VC6 x86 Thread Safe版本)
   3。解压php5.3到任意目录,找到PHP安装目录下的php.ini-development并改名为php.ini文件,开始配置:
        ; date.timezone =             改为   date.timezone = Asia/Shanghai
        ; extension_dir = "ext"      改为   extension_dir = "./ext/" 
        ;error_reporting = E_ALL & ~E_DEPRECATED   去掉;
        ;display_errors = On                                            去掉;
        ;display_startup_errors = On                               去掉;
        ;error_prepend_string =                                       改为:"<font style='font-size:16px;color:#ff0000'>"
        ;error_append_string =                                        改为:"</font><br><br><br>"
        ;default_mimetype = "text/html"                            去掉;
       至于php.ini里面的extension开启方式,根据自己所需求开启所需功能。
    4。配置apache的配置文件:httpd.conf
       添加:
         LoadModule php5_module "D:/php/php-5.3.0/php5apache2_2.dll"
         PHPIniDir "D:/php/php-5.3.0"
         下面的模块,根据自己的需求开启。
         创建虚拟目录:
<VirtualHost 127.0.0.22:80>
    DocumentRoot D:/php/Apache2.2/htdocs1
    ServerName 127.0.0.22:80
    <Directory "D:/php/Apache2.2/htdocs1">
       Options Indexes FollowSymLinks
       DirectoryIndex index.html index.htm index.php
       AllowOverride All
       Order allow,deny
       Allow from all
    </Directory>
    ErrorLog  D:/php/Apache2.2/htdocs1/error.log
    LogLevel warn
    LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost
    CustomLog D:/php/Apache2.2/htdocs1/access.log vhost
</VirtualHost>

    OK了,运行一下看看效果吧。


300*300
  • 没有相关文章
  • 没有评论
 文章首页关于迷茫时代关于我写意人生
版权所有:迷茫时代 All rights reserved   
执行时间:0.00779 秒