2016-02-12 1 views
10

J'ai expérimenté un comportement étrange de déploiement azure php webrole, à chaque seconde de déploiement lorsque je navigue sur la page, il montre erreur erreur 500, mais si je publie à nouveau sans aucun changement que cela fonctionne, je 'ai essayé de trouver quelque chose dans l'observateur d'événements, mais il n'y a rienazure php webrole erreur aléatoire 500 sur déployer

enter image description here, des suggestions? Quelques informations de débogage: Lorsque cette erreur s'est produite, j'ai vérifié la configuration IIS en utilisant le bureau à distance J'ai remarqué que le gestionnaire PHP a un mauvais chemin spécifié par exemple F: \ wwwroot \ bin \ php \ php-cgi.exe mais sur le serveur chemin réel est E: \ wwwroot \ bin \ php \ php-cgi.exe Je pense que cette lettre de lecteur (F :) a suivi de mon système d'où je publie MAIS, comme je l'ai dit étrange est qu'une fois que cela fonctionne, mais quand je republier que l'erreur se produit ...

setup_web.cmd (je l'ai recopié à partir 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" 

MISE À JOUR: Après avoir travaillé autour de ce problème, je pense que le problème est suivant: J'ai mon dossier de projet sur E: \ drive, quand je publie la première fois azure crée E: \ drive et définit le chemin du gestionnaire php en utilisant cmdlets, mais quand je publie nouveau supprime azur lecteur E: \ et crée le lecteur F: \ et essaie de confugre IIS à nouveau peu qu'il renvoie des erreurs suivantes:

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" 

Je suppose que cela peut \ 't définir la configuration de PHP car il est a été fixé et donc jette des erreurs en double

J'ai donc besoin de quelque chose comme ceci: soit faire en sorte que les lettres des lecteurs ne changent pas lors de la publication ou changer le script de configuration en utilisant followi ng scénario: supprimez d'abord la configuration IIS existante pour éviter les erreurs en double et ajoutez-la à nouveau.

+0

Quelle est la version de PHP utilisée dans le cloud? Et selon votre autre question http://stackoverflow.com/questions/35357846/change-document-root-on-azure-php-webrole, dose ce problème se produit dans l'application laracel? quelle version de laravel vous utilisez? Comme c'est un peu difficile de reproduire ce problème de mon côté. –

+0

Oui, il se produit dans l'application Laravel, j'utilise php 5.6 – Phoebus

+0

Une chose que j'ai remarqué est que, lorsque je publie paquet et erreur se produit le gestionnaire php dans la configuration IIS a un mauvais chemin spécifié – Phoebus

Répondre

3

Vous devez supprimer le chemin de PHP précédent dans la configuration puis définissez la nouvelle, par exemple, vous devez mettre cette ligne:

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

avant:

%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

Merci de m'avoir aidé à écrire un script de configuration complet, alors j'accepte votre réponse et je vais mettre à jour ma question avec le script de configuration. – Phoebus

2

Après maxmayer suggestion, j'ai corrigé setup_script

Copie de travail complète du 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