我已經按照這裏的指示:Using FastCGI to Host PHP Applications on IIS 7來配置Windows 2008,PHP與IIS 7和FastCGI,我遇到了問題。 PHP版本是5.3.8。我已經在IIS上設置了處理程序映射,並創建了一個測試頁面,但該頁面除了發生500錯誤外不會返回任何內容。我已經確保了PHP的作品,在命令行中我得到迴應,當我進入:PHP IIS 7和FastCGI不工作
php -version.
這麼說,我已經打開失敗請求跟蹤的PHP網頁的規則,當我瀏覽過的錯誤日誌,我看到的東西,如:
<EventData>
<Data Name="ContextId">{00000000-0000-0000-0200-0080010000F6}</Data>
<Data Name="ModuleName">FastCgiModule</Data>
<Data Name="Data1">FASTCGI_RESPONSE_ERROR</Data>
<Data Name="Data2">PHP Warning: phpinfo() [<a href='function.phpinfo'>function.phpinfo</a>]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for '-4.0/DST' instead in C:\inetpub\wwwroot\phpinfo.php on line 1
</Data>
<Data Name="ErrorCode">5</Data>
</EventData>
<RenderingInfo Culture="en-US">
<Opcode>MODULE_WARNING</Opcode>
<Keywords>
<Keyword>Module</Keyword>
</Keywords>
<freb:Description Data="ErrorCode">Access is denied.
(0x5)</freb:Description>
從失敗請求日誌的頂部,我可以看到它的IUSR帳戶下運行:
tokenUserName="NT AUTHORITY\IUSR"
下面是FastCGI的設置:
<fastCgi>
<application fullPath="C:\PHP\php-cgi.exe" instanceMaxRequests="10000">
<environmentVariables>
<environmentVariable name="PHP_FCGI_MAX_REQUESTS" value="10000" />
<environmentVariable name="PHPRC" value="C:\php\php.ini" />
</environmentVariables>
</application>
</fastCgi>
<handlers accessPolicy="Read, Script">
<add name="PHP via FastCGI" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="C:\PHP\php-cgi.exe" resourceType="Unspecified" requireAccess="Script" />
我確定這個用戶名可以完全控制我的C:\ PHP目錄。我的php.ini文件在C:\ PHP目錄中配置。
除了下面該文章中的方向,我也試圖創建一個PHP腳本映射,我創建的時候,我得到了一個差異的錯誤,而不是500
HTTP Error 403.1 - Forbidden
You have attempted to run a CGI, ISAPI, or other executable program from a directory that does not allow executables to run.
儘管曾經,IUSR可以完全控制該目錄,所以我不太明白爲什麼會出現這樣的錯誤信息。
更新 這個問題在我的日誌中很明顯。我已經忽略了關於date.timezone的PHP警告,認爲這只是一個警告。我將它設置爲:
date.timezone = America/New_York
現在它工作。
哇,這會更容易。我將保存此鏈接供將來參考。 – mservidio