展会信息港展会大全

Windows2003+IIS7 Express使用FastCgi运行php
来源:互联网   发布日期:2016-03-02 15:36:03   浏览:2092次  

导读:想在windows 2003中好好跑php,又要节省内存,真是很为难的事情,考虑到IIS7.5 Express可以在WIN2003上跑,不但能以fastcgi的方式支持php,还自带Rewrit...

想在windows 2003中好好跑php,又要节省内存,真是很为难的事情,考虑到IIS7.5 Express可以在WIN2003上跑,不但能以fastcgi的方式支持php,还自带Rewrite组件,只需简单改改web.config的rule规则就可以了。

于是下载了IIS7.5 Express后,安装,还需要对applicationHost.config进行配置,首先得找到这个文件在哪里,如果能在"我的文档"中IIS7Express目录下找到,那就是它了,否则应该就是在IIS7 Express的安装目录下。

1、先修改:defaultDocument节,加入 <add value="index.php" />

<defaultDocument enabled="true">

<files>

<add value="Default.htm" />

<add value="Default.asp" />

<add value="index.htm" />

<add value="index.html" />

<add value="iisstart.htm" />

<add value="default.aspx" />

<add value="index.php" />

</files>

</defaultDocument>

2、找到fastcgi节。

<fastCgi>

<application fullPath="C:phpphp-cgi.exe" monitorChangesTo="php.ini" activityTimeout="600" requestTimeout="600" instanceMaxRequests="10000">

<environmentVariables>

<environmentVariable name="PHP_FCGI_MAX_REQUESTS" value="10000" />

<environmentVariable name="PHPRC" value="C:Program Files (x86)iis expressPHPv5.4" />

</environmentVariables>

</application>

</fastCgi>

3、找到handlles,加入

<add name="PHP_FastCGI" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:PHPphp-cgi.exe" resourceType="Either" />

尤其要注意的一是,这一句最好加在最前面,也就是在<handlles>下面的第一句,避免被其它Handle抢先处理了。

以上配置中,C:phpphp-cgi.exe 的部分替换成自己的php文件夹中的php-cgi.exe的位置。

4、在<site>配置节下,直接修改站点信息,或直接用appcmd.exe add site来添加站点。

5、找到诸如wordpress的安装文件夹,创建一个web.config文件,在configuration配置节下,添加Gzip压缩规则。

<system.webServer>

<urlCompression doStaticCompression="true" doDynamicCompression="true" />

</system.webServer>

6、同样在web.config中,Wordpress的rewrite完整的web.config文件内容如下:

<configuration>

<system.webServer>

<rewrite>

<rules>

<rule name="wordpress" patternSyntax="Wildcard">

<match url="*" />

<conditions>

<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />

</conditions>

<action type="Rewrite" url="index.php" />

</rule>

</rules>

</rewrite>

</system.webServer>

<system.webServer>

<urlCompression doStaticCompression="true" doDynamicCompression="true" />

</system.webServer>

</configuration>

这样就完全配置完毕了,然后在IIS7 Express目录下,找到IISExpress.exe,直接双击运行,或者用命令行来执行指定加载哪个站点.

iisexpress.exe /site:'站点名称1"

iisexpress.exe /site:'站点名称2"

访问一下,就会发现访问速度比在windows下使用apache要快得多,而且少跑一个nginx,内存占用整体上也少了很多。

赞助本站

人工智能实验室

相关热词: 开发 编程 android

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港