【Azure App Service for Windows】 PHP应用出现500 : The page cannot be displayed because an internal server error has occurred. 错误

发布时间 2023-07-05 21:08:39作者: 路边两盏灯

问题描述

PHP应用突然遇见了500 The page cannot be displayed because an internal server error has occurred.错误,但是如果访问一个静态HTML页面,就可以成功。只要是PHP页面,就是500。

 

问题解答

登录App Service的Kudu站点,查看日志发现一句:  scriptProcessor could not be found in "fastCGI" application configuration. 

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
 <System>
  <Provider Name="WWW Server" Guid="{3A2A4E84-4C21"/>
  <EventID>0</EventID>
  <Version>1</Version>
  <Level>3</Level>
  <Opcode>18</Opcode>
  <Keywords>0x100</Keywords>
  <TimeCreated SystemTime="2023-07-05T07:35:06.598Z"/>
  <Correlation ActivityID="{800003B}"/>
  <Execution ProcessID="6616" ThreadID="2832"/>
  <Computer>dw</Computer>
 </System>
 <EventData>
  <Data Name="ContextId">{8000031E-0000--}</Data>
  <Data Name="ErrorDescription">&lt;handler&gt; scriptProcessor could not be found in &lt;fastCGI&gt; application configuration</Data>
 </EventData>
 <RenderingInfo Culture="zh-CN">
  <Opcode>SET_RESPONSE_ERROR_DESCRIPTION</Opcode>
  <Keywords>
   <Keyword>RequestNotifications</Keyword>
  </Keywords>
 </RenderingInfo>
 <ExtendedTracingInfo xmlns="http://schemas.microsoft.com/win/2004/08/events/trace">
  <EventGuid>{00E}</EventGuid>
 </ExtendedTracingInfo>
</Event>

错误消息显示因为脚本处理器(scriptProcessor)无法找到 fastCGI 模块。 而这个 fastCGI 是通过web.config配置,直接从App Service的实例中获取。

接下来,查看PHP的 FastCGI 处理程序 php_cgi.exe的路径。 

然后,查看web.config中配置的路径,发现路径配置为D:\Program Files\...., 所以,尝试修改 FastCGI中 ScriptProcessor的路径为 C:\ 。 

组后,保存修改。重新访问页面返回200成功。

 

解决了 scriptProcessor could not be found in "fastCGI" application configuration 问题。