PHP CGI - misbehaved by not returning a complete set of HTTP headers


I have IIS7 and trying to render a sample PHP script. Please note that I have windows authentication set as ON:

   echo "Content-Type: text/html";
   echo "\n";  
   echo "BEGIN\n";
   echo "END";

But I get the below error:

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="">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="">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

But :

In 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

Please let me know how can I resolve this? Actually I need the value of $_SERVER['LOGON_USER'] variable to know which intranet user is visiting our intranet site?


The issue got resolved by modifying the php.ini file - it seems some default configuration where set as OFF which needs to be turned on:

asked on Stack Overflow Sep 17, 2012 by Programmer • edited Sep 18, 2012 by Programmer

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0