簡體   English   中英

部署時Azure PHP Webrole隨機錯誤500

[英]Azure php webrole random error 500 on deploy

我遇到過azure php webrole部署的奇怪行為,當我瀏覽頁面時每秒顯示錯誤500錯誤時都會發生奇怪的行為,但是如果我再次發布但未做任何更改,但我嘗試在事件查看器中找到某些內容沒什么

在此處輸入圖片說明 , 有什么建議么?

一些調試信息:發生該錯誤時,我使用遠程桌面檢查了IIS配置,我注意到PHP處理程序指定了錯誤的路徑,例如F:\\ wwwroot \\ bin \\ php \\ php-cgi.exe,但在服務器上的真實路徑為E: \\ wwwroot \\ bin \\ php \\ php-cgi.exe我認為驅動器號(F :)從我發布BUT的系統中傳來,因為我說奇怪的是,它一次可以工作,但是當我再次發布它時,錯誤發生...

setup_web.cmd(我已經從https://azure.microsoft.com/zh-cn/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"

更新:解決此問題后,我認為問題出在以下地方:我第一次發布Azure時,我的項目文件夾位於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路徑,然后設置新路徑,例如,必須放置以下行:

%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建議之后,我更正了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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM