PHP IIS 7 和 FastCGI 不工作
我按照此处的说明进行操作: 使用 FastCGI 在 IIS 7 上托管 PHP 应用程序来配置 Windows 2008、PHP 与 IIS 7 和 FastCGI,但我遇到了问题。 PHP版本是5.3.8。我已经在 IIS 上设置了处理程序映射,并创建了一个测试页面,尽管该页面除了 500 错误之外不返回任何内容。我已经确保 PHP 可以正常工作,从命令行输入以下内容时我会得到响应:
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
现在它可以工作了。
I've followed the directions here: Using FastCGI to Host PHP Applications on IIS 7 to configure Windows 2008, PHP with IIS 7 and FastCGI, and I'm running into issues. The PHP version is 5.3.8. I've setup the Handler Mappings on IIS, and created a test page, though the page doesn't return anything except for a 500 error. I've ensured that PHP works, from the command line I get a response when I enter:
php -version.
That said, I've turned on Failed Request Tracing Rules for php pages, and when I browse through the error log, I see things like:
<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>
From the top of the failed request log, I can see it's running under IUSR account:
tokenUserName="NT AUTHORITY\IUSR"
Here's settings for the 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" />
I've ensure that this user name has full control over my C:\PHP directory. My php.ini file is configured within C:\PHP directory.
In addition to following the directions in that article, I also tried to create a script map for PHP, and when I created that I got a difference error, not a 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.
Once again though, IUSR has full control over that directory so I don't quite understand why that error message.
Update
The issue was glaring right at me in the log. I had ignored the PHP Warning with regard to the date.timezone thinking that it's just a warning. I set it to:
date.timezone = America/New_York
and now it works.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了将来参考,您可以使用 http://php.iis.net/ 轻松地将 php 安装到您的 IIS 设置中。它带有一个管理器,它还可以让您进入“开发模式”,该模式将显示 php 错误而不是掩盖它们。
For future reference you can use http://php.iis.net/ to easily install php into your IIS setup. It comes with a manager which will also let you go into 'development mode' which will display php errors as opposed to covering them up.