Windows2003+IIS7 Express使用FastCgi運行php
想在windows 2003中好好跑php,又要節省內存(cún),真是很(hěn)為難的事情,考慮到IIS7.5 Express可以在WIN2003上跑,不但能以fastcgi的方式支持php,還自帶Rewrite組件,隻需簡單(dān)改改web.config的(de)rule規(guī)則就可(kě)以了。
於是下載了IIS7.5 Express後,安裝,還(hái)需要對applicationHost.config進(jìn)行配置,首先得找到這個文件在哪裏(lǐ),如果能在"我的文檔"中IIS7Express目錄下找到(dào),那就是它了(le),否則應(yīng)該就是在IIS7 Express的安裝目錄下。
1、先修改:defaultDocument節,加入(rù) <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:\php\php-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:\PHP\php-cgi.exe" resourceType="Either" />
尤其要注意的一是,這一句最好加(jiā)在最前麵,也就是在(zài)<handlles>下麵(miàn)的第一句,避免被(bèi)其它Handle搶先處理了。
以上配置中,C:\php\php-cgi.exe 的部分替(tì)換成(chéng)自己的php文件夾中的php-cgi.exe的(de)位置。
4、在<site>配置節下,直接修改站(zhàn)點信息,或(huò)直接用appcmd.exe add site來添加站點。
5、找到(dào)諸如wordpress的安裝文件夾(jiá),創建一個web.config文件,在configuration配(pèi)置節下,添加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>
這樣就完全配置完畢了(le),然後在IIS7 Express目錄下,找到IISExpress.exe,直接(jiē)雙擊運行,或者用命令行來(lái)執行指定加載哪個站點.
iisexpress.exe /site:'站點名稱(chēng)1"
iisexpress.exe /site:'站點名稱(chēng)2"
訪問一下,就會發(fā)現(xiàn)訪問速度比在(zài)windows下使用apache要快得多,而且少(shǎo)跑一個nginx,內存占用整體上也少了很多。
關鍵詞:Windows2003,IIS7,FastCgi,php
閱讀本(běn)文後您有什(shí)麽(me)感想? 已有 人給(gěi)出評價!
- 1
- 1
- 1
- 1
- 1
- 1