【问题标题】:Azure php webrole random error 500 on deploy部署时 Azure php webrole 随机错误 500
【发布时间】:2016-02-12 11:20:16
【问题描述】:

我遇到过 azure php webrole 部署的奇怪行为,当我浏览页面时,每隔一次部署它就会显示错误 500 错误,但是如果我再次发布而没有任何更改而不是它的工作原理,我试图在事件中找到一些东西查看器,但什么都没有

,有什么建议吗?

一些调试信息: 发生该错误时,我使用远程桌面检查了 IIS 配置\php\php-cgi.exe 我认为驱动器号 (F:) 来自我发布的系统 但是,正如我所说的奇怪的是,它有一次可以工作,但是当我再次发布它时,就会发生错误......

setup_web.cmd(我是从https://azure.microsoft.com/en-us/documentation/articles/cloud-services-php-create-web-role/复制过来的)

@ECHO ON
cd "%~dp0"

if "%EMULATED%"=="true" exit /b 0

msiexec /i sqlncli.msi /qn IACCEPTSQLNCLILICENSETERMS=YES

SET PHP_FULL_PATH=%~dp0php\php-cgi.exe
SET NEW_PATH=%PATH%;%RoleRoot%\base\x86

%WINDIR%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='%PHP_FULL_PATH%',maxInstances='12',idleTimeout='60000',activityTimeout='3600',requestTimeout='60000',instanceMaxRequests='10000',protocol='NamedPipe',flushNamedPipe='False']" /commit:apphost
%WINDIR%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='%PHP_FULL_PATH%'].environmentVariables.[name='PATH',value='%NEW_PATH%']" /commit:apphost
%WINDIR%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='%PHP_FULL_PATH%'].environmentVariables.[name='PHP_FCGI_MAX_REQUESTS',value='10000']" /commit:apphost
%WINDIR%\system32\inetsrv\appcmd.exe set config -section:system.webServer/handlers /+"[name='PHP',path='*.php',verb='GET,HEAD,POST,OPTIONS',modules='FastCgiModule',scriptProcessor='%PHP_FULL_PATH%',resourceType='Either',requireAccess='Script']" /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config /section:urlCompression /doDynamicCompression:True /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config  -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/json; charset=utf-8',enabled='True']" /commit:apphost
%WINDIR%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /"[fullPath='%PHP_FULL_PATH%'].queueLength:50000"

更新: 解决此问题后,我认为问题如下: 我在 E:\ 驱动器上有我的项目文件夹,当我第一次发布时 azure 创建 E:\ 驱动器并使用 cmdlet 设置 php 处理程序路径,但是当我再次发布时,azure 删除驱动器 E:\ 并创建驱动器 F:\ 并尝试再次配置 IIS 会引发以下错误:

F:\approot\bin>cd "F:\approot\bin\" 

F:\approot\bin>if "false" == "true" exit /b 0 

F:\approot\bin>msiexec /i sqlncli.msi /qn IACCEPTSQLNCLILICENSETERMS=YES 

F:\approot\bin>SET PHP_FULL_PATH=F:\approot\bin\php\php-cgi.exe 

F:\approot\bin>SET NEW_PATH=D:\Windows\system32;D:\Windows;D:\Windows\System32\Wbem;D:\Windows\System32\WindowsPowerShell\v1.0\;;F:\base\x64;F:\base\x86;;D:\Packages\GuestAgent\GuestAgent\LegacyRuntime\x64;D:\Packages\GuestAgent\GuestAgent\LegacyRuntime\x86;;F:\base\x86 

F:\approot\bin>D:\Windows\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='F:\approot\bin\php\php-cgi.exe',maxInstances='12',idleTimeout='60000',activityTimeout='3600',requestTimeout='60000',instanceMaxRequests='10000',protocol='NamedPipe',flushNamedPipe='False']" /commit:apphost 
ERROR ( message:New application object missing required attributes. Cannot add duplicate collection entry of type 'application' with combined key attributes 'fullPath, arguments' respectively set to 'F:\approot\bin\php\php-cgi.exe, '

. )

F:\approot\bin>D:\Windows\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='F:\approot\bin\php\php-cgi.exe'].environmentVariables.[name='PATH',value='D:\Windows\system32;D:\Windows;D:\Windows\System32\Wbem;D:\Windows\System32\WindowsPowerShell\v1.0\;;F:\base\x64;F:\base\x86;;D:\Packages\GuestAgent\GuestAgent\LegacyRuntime\x64;D:\Packages\GuestAgent\GuestAgent\LegacyRuntime\x86;;F:\base\x86']" /commit:apphost 
ERROR ( message:New environmentVariable object missing required attributes. Cannot add duplicate collection entry of type 'environmentVariable' with unique key attribute 'name' set to 'PATH'

. )

F:\approot\bin>D:\Windows\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='F:\approot\bin\php\php-cgi.exe'].environmentVariables.[name='PHP_FCGI_MAX_REQUESTS',value='10000']" /commit:apphost 
ERROR ( message:New environmentVariable object missing required attributes. Cannot add duplicate collection entry of type 'environmentVariable' with unique key attribute 'name' set to 'PHP_FCGI_MAX_REQUESTS'

. )

F:\approot\bin>D:\Windows\system32\inetsrv\appcmd.exe set config -section:system.webServer/handlers /+"[name='PHP',path='*.php',verb='GET,HEAD,POST,OPTIONS',modules='FastCgiModule',scriptProcessor='F:\approot\bin\php\php-cgi.exe',resourceType='Either',requireAccess='Script']" /commit:apphost 
ERROR ( message:New add object missing required attributes. Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'PHP'

. )

F:\approot\bin>D:\Windows\system32\inetsrv\appcmd.exe set config /section:urlCompression /doDynamicCompression:True /commit:apphost 
Applied configuration changes to section "system.webServer/urlCompression" for "MACHINE/WEBROOT/APPHOST" at configuration commit path "MACHINE/WEBROOT/APPHOST"

F:\approot\bin>D:\Windows\system32\inetsrv\appcmd.exe set config  -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/json; charset=utf-8',enabled='True']" /commit:apphost 
ERROR ( message:New add object missing required attributes. Cannot add duplicate collection entry of type 'add' with unique key attribute 'mimeType' set to 'application/json; charset=utf-8'

. )

F:\approot\bin>D:\Windows\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /"[fullPath='F:\approot\bin\php\php-cgi.exe'].queueLength:50000" 
Applied configuration changes to section "system.webServer/fastCgi" for "MACHINE/WEBROOT/APPHOST" at configuration commit path "MACHINE/WEBROOT/APPHOST"

所以我猜它不能设置 php 的配置,因为它已被设置,因此会引发重复错误

所以我需要这样的东西:要么使驱动器号在发布时不更改,要么使用以下方案更改配置脚本:首先删除现有的 IIS 配置以避免重复错误,然后再次添加。

【问题讨论】:

  • 您在云服务中使用的 PHP 版本是什么?根据您的另一个问题stackoverflow.com/questions/35357846/…,这个问题是否发生在 laracel 应用程序中?你使用哪个版本的 laravel?因为在我这边重现这个问题有点困难。
  • 是的,它发生在 Laravel 应用程序中,我使用的是 php 5.6
  • 我注意到的一件事是,当我发布包并发生错误时,IIS 配置中的 php 处理程序指定了错误的路径
  • 我正在使用 powershell 命令从 Windows 10 发布
  • 我已经在描述中添加了一些调试信息,如果没有答案请投票问题..

标签: php azure azure-web-roles


【解决方案1】:

你要在配置中去掉之前的PHP路径,然后设置新的,比如你要放这一行:

%WINDIR%\system32\inetsrv\appcmd.exe set config -section:system.webServer/handlers /-"[name='PHP']" /commit:apphost

之前:

%WINDIR%\system32\inetsrv\appcmd.exe set config -section:system.webServer/handlers /+"[name='PHP',path='*.php',verb='GET,HEAD,POST,OPTIONS',modules='FastCgiModule',scriptProcessor='%PHP_FULL_PATH%',resourceType='Either',requireAccess='Script']" /commit:apphost

【讨论】:

  • 感谢您帮助我编写了完整的安装脚本,因此我接受您的回答,我将使用有效的安装脚本更新我的问题。
【解决方案2】:

根据 maxmayer 的建议,我更正了 setup_script

脚本的完整工作副本:

@ECHO ON
cd "%~dp0"

if "%EMULATED%"=="true" exit /b 0

msiexec /i sqlncli.msi /qn IACCEPTSQLNCLILICENSETERMS=YES

SET PHP_FULL_PATH=%~dp0php\php-cgi.exe
SET NEW_PATH=%PATH%;%RoleRoot%\base\x86

%WINDIR%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /-"[maxInstances='12',idleTimeout='60000',activityTimeout='3600',requestTimeout='60000',instanceMaxRequests='10000',protocol='NamedPipe',flushNamedPipe='False']" /commit:apphost
%WINDIR%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='%PHP_FULL_PATH%',maxInstances='12',idleTimeout='60000',activityTimeout='3600',requestTimeout='60000',instanceMaxRequests='10000',protocol='NamedPipe',flushNamedPipe='False']" /commit:apphost
%WINDIR%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='%PHP_FULL_PATH%'].environmentVariables.[name='PATH',value='%NEW_PATH%']" /commit:apphost
%WINDIR%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='%PHP_FULL_PATH%'].environmentVariables.[name='PHP_FCGI_MAX_REQUESTS',value='10000']" /commit:apphost
%WINDIR%\system32\inetsrv\appcmd.exe set config -section:system.webServer/handlers /-"[name='PHP']" /commit:apphost
%WINDIR%\system32\inetsrv\appcmd.exe set config -section:system.webServer/handlers /+"[name='PHP',path='*.php',verb='GET,HEAD,POST,OPTIONS',modules='FastCgiModule',scriptProcessor='%PHP_FULL_PATH%',resourceType='Either',requireAccess='Script']" /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config /section:urlCompression /doDynamicCompression:True /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config  -section:system.webServer/httpCompression /-"dynamicTypes.[mimeType='application/json; charset=utf-8',enabled='True']" /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config  -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/json; charset=utf-8',enabled='True']" /commit:apphost
%WINDIR%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /"[fullPath='%PHP_FULL_PATH%'].queueLength:50000"

REM  clear Laravel cache
cd ..
%~dp0php\php.exe artisan clear-compiled
%~dp0php\php.exe artisan cache:clear
%~dp0php\php.exe artisan config:cache

【讨论】:

    猜你喜欢
    • 2013-10-22
    • 1970-01-01
    • 1970-01-01
    • 2020-03-16
    • 2012-03-23
    • 1970-01-01
    • 1970-01-01
    • 2021-06-28
    • 1970-01-01
    相关资源
    最近更新 更多