赞
踩
今天部署华为云,提示如下错误:
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> ".
-----------------------------
大意是说指定的 CGI 应用程序由于未返回完整的一组 HTTP 头而产生错误行为。
-----------------------------
服务器:
系统:Microsoft Windows Server 2019 Datacenter
版本:10.0.17763 N/A Build 17763
-----------------------------
解决方案:
一、微软下载安装 vc_redist.x64.exe 包:
https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-170
-----------------------------
二、设置服务器显示详细错误:
<system.web>
<customErrors mode="Off" />
</system.web>
<system.webServer>
<httpErrors errorMode="Detailed" />
</system.webServer>
-----------------------------
三、关闭 php.ini 中的强制重定向项(它可以防止当PHP运行的CGI脚本未经验证的访问)
cgi.force_redirect = 0
官方描述:
cgi.force_redirect bool
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.
Note:
Windows Users: When using IIS this option must be turned off. For OmniHTTPD or Xitami the same applies.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。