IIS The PHP CGI cannot be accessed directly.

php 发表于 2017/10/14 15:27 | 显示全部楼层 |阅读模式
 IIS The PHP CGI cannot be accessed directly. HTTP 错误 502.2 - Bad Gateway 指定的 CGI 应用程序由于未返回完整的一组 HTTP 头而产生错误行为。它实际返回的头是“Security Alert! The PHP CGI cannot be accessed directly.

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.

For more information as to why this behaviour exists, see the manual page for CGI security.

For more information about changing this behaviour or re-enabling this webserver, consult the installation file that came with this distribution, or visit the manual page.

”。解决方法：打开生效的PHP配置文件php.ini，搜索cgi.force_redirect，将值修改为0，即cgi.force_redirect = 0 即可。 cgi.force_redirect is necessary to provide security running PHP as a CGI under most web servers. Left undefined, PHP turns this on by default. You can turn it off at your own risk. Windows Users: When using IIS this option must be turned off. For OmniHTTPD or Xitami the same applies. 该配置项默认值为1，在IIS中运行PHP必须将cgi.force_redirect配置为0才能正常运行。

E-mail: OHCC@163.COM