从浏览器请求.html页面时出现IIS 10错误(指定的CGI应用程序遇到错误)

从浏览器请求.html页面时出现IIS 10错误(指定的CGI应用程序遇到错误),html,iis,cgi,config,Html,Iis,Cgi,Config,从浏览器请求.html页面时出现IIS 10错误(指定的CGI应用程序遇到错误) 我正在尝试在Windows server 2019上新安装的IIS 10上重建网站。(这是一个在Windows2008R2测试框上运行良好的站点。)当我进入浏览器并请求index.html时,我会收到一条错误消息“指定的CGI应用程序遇到错误,服务器终止了进程。”当我将页面重命名为index.htm时,它会正常工作 浏览器控制台中的错误显示:未声明HTML文档的字符编码。如果文档包含US-ASCII范围之外的字符,

从浏览器请求.html页面时出现IIS 10错误(指定的CGI应用程序遇到错误)

我正在尝试在Windows server 2019上新安装的IIS 10上重建网站。(这是一个在Windows2008R2测试框上运行良好的站点。)当我进入浏览器并请求index.html时,我会收到一条错误消息“指定的CGI应用程序遇到错误,服务器终止了进程。”当我将页面重命名为index.htm时,它会正常工作

浏览器控制台中的错误显示:未声明HTML文档的字符编码。如果文档包含US-ASCII范围之外的字符,则在某些浏览器配置中,文档将呈现乱码文本。页面的字符编码必须在文档或传输协议中声明

但是页面字符编码是正确声明的,并且在另一台服务器上运行良好

我的web.config如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpProtocol>
            <customHeaders>
                <add name="X-XSS-Protection" value="1; mode=block" />
            </customHeaders>
        </httpProtocol>
        <handlers>
            <clear />
            <add name="PHP" path="*.html,*.php" verb="*" type="" modules="FastCgiModule" scriptProcessor="C:\PHP\php-cgi.exe" resourceType="File" requireAccess="Script" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
            <add name="HTMLPHPMapping" path="*.html" verb="*" type="" modules="CgiModule" scriptProcessor="C:\php7\php-cgi.exe" resourceType="File" requireAccess="Script" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
            <add name="PHP74Mapping" path="*.php" verb="*" type="" modules="FastCgiModule" scriptProcessor="C:\php7\php-cgi.exe" resourceType="File" requireAccess="Script" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
            <add name="CGI-exe" path="*.exe" verb="*" type="" modules="CgiModule" scriptProcessor="" resourceType="File" requireAccess="Execute" allowPathInfo="true" preCondition="" responseBufferLimit="4194304" />
            <add name="TRACEVerbHandler" path="*" verb="TRACE" type="" modules="ProtocolSupportModule" scriptProcessor="" resourceType="Unspecified" requireAccess="None" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
            <add name="OPTIONSVerbHandler" path="*" verb="OPTIONS" type="" modules="ProtocolSupportModule" scriptProcessor="" resourceType="Unspecified" requireAccess="None" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
            <add name="StaticFile" path="*" verb="*" type="" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" scriptProcessor="" resourceType="Either" requireAccess="Read" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
        </handlers>
        <httpErrors errorMode="Custom" defaultResponseMode="File">
            <clear />
            <error statusCode="500" path="index.html" />
            <error statusCode="404" path="index.html" />
        </httpErrors>
        <defaultDocument>
            <files>
                <clear />
                <add value="index.html" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="iisstart.htm" />
            </files>
        </defaultDocument>
        <security>
            <requestFiltering>
                <fileExtensions>
                    <add fileExtension=".html" allowed="true" />
                </fileExtensions>
            </requestFiltering>
        </security>
    </system.webServer>
</configuration>


您是否正确设置了处理程序?我们总是为PHP cgi创建模块映射,就像 这个



1)PHP不需要那么多处理程序。只要第一个就足够了。2) 使用FRT了解有关CGI错误的更多信息。你可以编辑这个问题以包含FRT日志的重要部分。谢谢Lex Li,我会这样做并回复。我想知道为什么我看不到错误日志。谢谢!它正在工作。那些映射把一切都搞砸了。@dupnic。我很高兴我的回答能帮上忙。如果你能接受它作为答案,那就太好了。
        <handlers>
            <clear />
            <add name="phpmaphtml" path="*.html" verb="*" modules="FastCgiModule" scriptProcessor="C:\Program Files\PHP\v7.3.9\php-cgi.exe" resourceType="File" />
        </handlers>