PHP IIS 7和FastCGI无法正常工作

mse*_*dio 1 php iis iis-7 fastcgi windows-server-2008-r2

我按照这里的指示:使用FastCGI在IIS 7上托管PHP应用程序来配置Windows 2008,PHP与IIS 7和FastCGI,我遇到了问题.PHP版本是5.3.8.我在IIS上设置了Handler Mappings,并创建了一个测试页面,但页面除了500错误外没有返回任何内容.我确保PHP工作,从命令行我输入时得到响应:

php -version.
Run Code Online (Sandbox Code Playgroud)

也就是说,我已经为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() [&lt;a href=&apos;function.phpinfo&apos;&gt;function.phpinfo&lt;/a&gt;]: It is not safe to rely on the system&apos;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 &apos;America/New_York&apos; for &apos;-4.0/DST&apos; 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>
Run Code Online (Sandbox Code Playgroud)

从失败的请求日志的顶部,我可以看到它在IUSR帐户下运行:

tokenUserName="NT AUTHORITY\IUSR"
Run Code Online (Sandbox Code Playgroud)

这是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" />
Run Code Online (Sandbox Code Playgroud)

我确保这个用户名完全控制我的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.
Run Code Online (Sandbox Code Playgroud)

再一次,IUSR可以完全控制该目录,所以我不太明白为什么会出现这个错误信息.

更新 问题在日志中对我很明显.我忽略了关于date.timezone的PHP警告,认为它只是一个警告.我把它设置为:

date.timezone = America/New_York
Run Code Online (Sandbox Code Playgroud)

现在它的工作原理.

How*_*III 5

为了将来参考,您可以使用http://php.iis.net/轻松地将php安装到您的IIS设置中.它带有一个管理器,它也会让你进入'开发模式',它将显示php错误而不是覆盖它们.