2016-02-12 79 views
10

我已經經歷了蔚藍的PHP webrole部署的奇怪行爲,在每一秒部署時,我眉頭頁它顯示錯誤500錯誤,但如果我沒有任何變化再次發佈比它的作品,我已經嘗試找到在事件查看器的東西,但沒有什麼Azure的PHP webrole隨機誤差500

enter image description here,有什麼建議?

一些調試信息: 當發生錯誤時,我使用遠程桌面檢查IIS配置我注意到PHP處理程序指定了錯誤的路徑例如F:\ wwwroot \ bin \ php \ php-cgi.exe但在服務器上真正的路徑是E:\ wwwroot \ bin \ 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" 

UPDATE: 解決此問題的工作後,我覺得問題是以下幾點: 我第E我的項目文件夾:\驅動器,當我發佈首次蔚藍創建E:\驅動器和使用的cmdlet設置PHP處理路徑,但是當我發佈再次蔚藍刪除驅動器E:\和創建驅動器F:\並嘗試confugre 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的配置,因爲它已經被設置因此引發重複錯誤

所以我需要的東西是這樣的:要麼使這樣盤符不會更改在發佈或使用followi更改配置腳本ng方案:首先刪除現有的IIS配置,以避免重複的錯誤並重新添加。

+0

雲服務中使用的是什麼PHP版本?並根據你的另一個問題http://stackoverflow.com/questions/35357846/change-document-root-on-azure-php-webrole,劑量這個問題發生在laracel應用程序?你使用哪個版本的laravel?因爲在我這邊重現這個問題有點困難。 –

+0

是的,它發生在Laravel應用,我在使用PHP 5.6 – Phoebus

+0

我注意到的一件事是,當我發佈包和錯誤發生在IIS配置已經走錯了路指定 – Phoebus

回答

3

你要刪除以前的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 
+0

謝謝你,它幫助我編寫完整的安裝腳本,所以我接受你的答案,並用工作設置腳本更新我的問題。 – Phoebus

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