我有 IIS7 并试图呈现一个示例 PHP 脚本。请注意,我将 Windows 身份验证设置为 ON:
<?php
echo "Content-Type: text/html";
echo "\n";
echo "BEGIN\n";
echo "END";
?>
但我收到以下错误:
HTTP Error 502.2 - Bad Gateway
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are "<b>Security Alert!</b> The PHP CGI cannot be accessed directly. <p>This PHP CGI binary was compiled with force-cgi-redirect enabled. This means that a page will only be served up if the REDIRECT_STATUS CGI variable is set, e.g. via an Apache Action directive.</p> <p>For more information as to <i>why</i> this behaviour exists, see the <a href="http://php.net/security.cgi-bin">manual page for CGI security</a>.</p> <p>For more information about changing this behaviour or re-enabling this webserver, consult the installation file that came with this distribution, or visit <a href="http://php.net/install.windows">the manual page</a>.</p>"
Module CgiModule
Notification ExecuteRequestHandler
Handler PHP
Error Code 0x00000103
Requested URL http://localhost:8080/phpinfo.php
Physical Path C:\inetpub\wwwroot\phpinfo.php
Logon Method Anonymous
Logon User Anonymous
但 :
在 C:\PHP\php.ini 中:
cgi.force_redirect = 0
cgi.redirect_status_env = REDIRECT_STATUS
和
c:\PHP>php-cgi.exe C:\inetpub\wwwroot\phpinfo.php
X-Powered-By: PHP/5.2.17
Content-type: text/html
Content-Type: text/html
BEGIN
END
c:\PHP>
请让我知道我该如何解决这个问题?实际上我需要 $_SERVER['LOGON_USER'] 变量的值来知道哪个 Intranet 用户正在访问我们的 Intranet 站点?
::更新::
通过修改 php.ini 文件解决了这个问题 - 似乎一些默认配置设置为 OFF 需要打开:
http://www.thesitewizard.com/php/install-php-5-apache-windows.shtml