部署时出现Azure php webrole随机错误500

部署时出现Azure php webrole随机错误500,php,azure,azure-web-roles,Php,Azure,Azure Web Roles,我曾经体验过azure php webrole部署的奇怪行为,当我浏览页面时,每一秒部署都会显示error 500 error,但如果我再次发布,并且没有任何更改,那么我会尝试在事件查看器中查找一些内容,但什么都没有 ,有什么建议吗 一些调试信息: 当那个错误发生时,我使用远程桌面检查了IIS配置,我注意到PHP处理程序指定了错误的路径,例如F:\wwwroot\bin\PHP\PHP-cgi.exe,但在服务器上,实际路径是E:\wwwroot\bin\PHP\PHP-cgi.exe,我想驱动

我曾经体验过azure php webrole部署的奇怪行为,当我浏览页面时,每一秒部署都会显示error 500 error,但如果我再次发布,并且没有任何更改,那么我会尝试在事件查看器中查找一些内容,但什么都没有

,有什么建议吗

一些调试信息: 当那个错误发生时,我使用远程桌面检查了IIS配置,我注意到PHP处理程序指定了错误的路径,例如F:\wwwroot\bin\PHP\PHP-cgi.exe,但在服务器上,实际路径是E:\wwwroot\bin\PHP\PHP-cgi.exe,我想驱动器号(F:)是从我发布的系统中跟随的 但是,正如我所说,奇怪的是,有一次它可以工作,但当我再次发布它时,错误就发生了

setup_web.cmd(我从中复制了它)

更新: 在解决了这个问题后,我认为问题如下: 当我第一次发布azure创建E:\drive并使用cmdlet设置php处理程序路径时,我的项目文件夹位于E:\drive上,但当我再次发布时,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路径,然后设置新路径,例如,你必须写这行:

%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

根据maxmayer的建议,我更正了设置脚本

脚本的完整工作副本:

@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

云服务中使用的PHP版本是什么?根据你的另一个问题,这个问题是否发生在laracel应用程序中?您使用哪种版本的laravel?由于在我这边重现这个问题有点困难。是的,它发生在Laravel应用程序中,我使用的是PHP5.6,我注意到的一点是,当我发布软件包并出现错误时,IIS配置中的php处理程序指定了错误的路径我正在使用powershell命令从windows 10发布我在说明中添加了一些调试信息,如果没有答案,请向上投票问题..感谢您帮助我编写完整的安装脚本,所以我接受你的答案,我将用工作设置脚本更新我的问题。
@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