Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[教程] windows 2008 R2 下 IIS7.5+PHP+Mysql+Zend完美运行fastcgi

[复制链接]
pubcn 发表于 2009-12-11 16:26:24 | 显示全部楼层 |阅读模式
本帖最后由 pubcn 于 2010-10-26 08:48 编辑


windows 2008 R2 下面IIS7.5已经对fastcg的支持有了很大改进,我们不建议朋友们再使用PHP-ISAPi模式。
本次环境搭建所有版本均经过多次测试保证无误!鉴于目前php5.3.1还不能完美的支持主流php系统,不建议大家使用!
windows2008 R2下面环境搭建分三种情况 大家可以根据自己的运行需要选择!
1 IIS7.5+PHP+Mysql+Wincache 1.0RC
这个环境组合大家已经看出来了 没有zend,
各个版本分别是:
PHP5.2.11--请注意是非线程安全版本 PHP 5.2.11 Non-thread-safe zip package
MYSQL5.0 x64,
Wincache1.0rc for5.2,这个大家可以去微软IIS官方下载,他将极大地提高您的系统运行效率!
如果您的服务器运行的都是开源程序,不需要zend,强烈建议您使用这个配置!

2 IIS7.5+PHP+Mysql+Zend+Xcache
此组合版本分别是
PHP5.2.11 请注意是线程安全版本PHP 5.2.11 zip package
MYSQL5.0 x64,
ZendOptimizer3.3.3-windows x86
Xcache1.3 for XCache-1.3.0-php-5.2.10-Win32-VC6-x86.zip
此组合可以完美运行当今主流的PHP系统,但是美中不足的是使用PHP线程安全版本无法加载wincache,很遗憾的一点!但是可以用xcache作为补充,但是相比PHP-ISAPI模式已经好多了!

3 鉴于IIS7.5的新特性,我们可以根据每个站点的具体情况定制属于他的专有运行环境!
在iis7.5 fastcgi模式下,IIS官方建议为每个站点设立单独的应用池,并且每个站点都可以拥有它自己的PHP.ini以及fastcgi.exe.允许在一台主机上运行不同版本的PHP.

官方是这样描述的:Enabling per-site PHP configuration
The section describes the recommended way of enabling per-site PHP configuration . Note that this recommendation was discovered and validated by Radney Jasmin with hosting provider GoDaddy.com who now offers PHP hosting on Windows Server 2008 via FastCGI.Per-site PHP process pools
When each web site has its own application pool (which is a recommended practice on IIS 7.0), it is possible to associate a dedicated FastCGI process pool with each web site. A FastCGI process pool is uniquely identified by the combination of fullPath and arguments attributes. So, if it is necessary to create several FastCGI process pools for the same process executable, such as php-cgi.exe, the arguments attribute can be used to distinguish process pools definitions. In addition, with php-cgi.exe processes the command line switch "-d" can be used to define an INI entry for PHP process. This switch can be used to set a PHP setting that makes the arguments string unique.
For example, if there are two web sites "website1" and "website2" that need to have their own set of PHP settings, the FastCGI process pools can be defined as follows:
<fastCgi>
    <application fullPath="C:\PHP\php-cgi.exe" arguments="-d open_basedir=C:\Websites\Website1" />
    <application fullPath="C:\PHP\php-cgi.exe" arguments="-d open_basedir=C:\Websites\Website2" />
</fastCgi>

In this example the PHP setting open_basedir is used to distinguish between process pool definitions. In addition it enforces that the PHP executable for each process pool can perform file operations only within the root folder of the corresponding web site.
Then website1 can have the PHP handler mapping as follows:
<system.webServer>
    <handlers accessPolicy="Read, Script">
        <add name="PHP via FastCGI" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="C:\PHP\php-cgi.exe|-d open_basedir=C:\Websites\Website1" resourceType="Unspecified" requireAccess="Script" />
    </handlers>
</system.webServer>

and website2 can have the PHP handler mapping as follows:
<system.webServer>
    <handlers accessPolicy="Read, Script">
        <add name="PHP via FastCGI" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="C:\PHP\php-cgi.exe|-d open_basedir=C:\Websites\Website2" resourceType="Unspecified" requireAccess="Script" />
    </handlers>
</system.webServer>
Specifying php.ini location
When the PHP process starts it determines the location of the configuration php.ini file by using various settings. The PHP documentation provides detailed description of the PHP start up process. Note that one of the places where PHP process searches for php.ini location is the PHPRC environment variable. If PHP process finds a php.ini file in the path specified in this environment variable then it will use it, otherwise it will revert to default location of php.ini. This environment variable can be used to allow hosting customers to use their own versions of php.ini files.
For example if there are two websites: website1 and website2; located at the following file paths: C:\WebSites\website1 and C:\WebSites\website2 then the php-cgi.exe process pools in the <fastCgi> section of applicationHost.config can be configured as below:
<fastCgi>
    <application fullPath="C:\PHP\php-cgi.exe" arguments="-d open_basedir=C:\Websites\Website1">
        <environmentVariables>
            <environmentVariable name="PHPRC" value="C:\WebSites\website1" />
        </environmentVariables>
    </application>
    <application fullPath="C:\PHP\php-cgi.exe" arguments="-d open_basedir=C:\WebSites\Website2">
        <environmentVariables>
            <environmentVariable name="PHPRC" value="C:\WebSites\website2" />
        </environmentVariables>
    </application>
</fastCgi>

This way website1 can have its own version of php.ini in the C:\WebSites\website1, while website2 can have its own version of php.ini located in C:\WebSites\website2. This configuration also ensures that if there is no php.ini found in location specified by PHPRC environment variable then PHP will fall back to using the default php.ini file located in the same folder where php-cgi.exe is located.
具体设置请参考IIS官方说明:Using FastCGI to Host PHP Applications on IIS 7.0


有需要windows 2008 R2系统服务的朋友 请联系!qq 5343726
 楼主| pubcn 发表于 2009-12-11 16:31:00 | 显示全部楼层
本帖最后由 pubcn 于 2009-12-11 16:46 编辑

至于具体的配置网上已经有很多朋友说明了 就不必再多说了 强调的是windows 2008 R2 下面 PHP-fastcgi并非一定要和PHP --Non-thread-safe 搭配才行,不然会陷入误区!大家可以根据自己的需要灵活配置,以达到最佳性能! 我们的服务器系统已经升级至windows 2008 R2 ENT并稳定运行中!欢迎大家交流!QQ 5343726
回复

使用道具 举报

有心人 发表于 2009-12-13 04:36:12 | 显示全部楼层
我是2008 R2
PHP v5.2.11
MySQL 版本 5.1.41

用WEBUI好像安装默认PHP运行fastcgi,请问装ZEND支持吗?
回复

使用道具 举报

 楼主| pubcn 发表于 2009-12-14 11:08:27 | 显示全部楼层
楼上的朋友 是否支持zend要看您的php版本· 只有php-ts版本才可以正常检测到zend,虽然微软一再强调在IIS平台上运行fastcgi最好用php-nts版本!但是为了运行某些不开源的系统,比如shopex,你只能用php-ts!
回复

使用道具 举报

有心人 发表于 2009-12-14 18:55:15 | 显示全部楼层
php-ts版本是什么意思?

请问你QQ是什么,请教下
回复

使用道具 举报

 楼主| pubcn 发表于 2009-12-15 15:04:19 | 显示全部楼层
PHP 5.2.11 zip package 这个版本运行fastcgi可以正常检测到zend!
回复

使用道具 举报

 楼主| pubcn 发表于 2009-12-15 15:06:55 | 显示全部楼层
也即是安全线程版本的php! 这个很多朋友也提到过!如果你要使用zend,运行fastcgi模式 必须这个版本!
回复

使用道具 举报

zjxubinbin 发表于 2009-12-31 18:53:48 | 显示全部楼层
收藏了...........
回复

使用道具 举报

loongme 发表于 2010-1-1 16:35:43 | 显示全部楼层
试了很久,不知有用否,试一下,谢过了
回复

使用道具 举报

SMG免费虚拟主机 发表于 2010-1-2 15:11:41 | 显示全部楼层
FASTCGI比原来的各种解析方式要好的多了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-11-23 10:47 , Processed in 0.033856 second(s), 5 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表