2017-05-19 2 views
0

J'essaie de déployer une page php de base avec l'extension html chez Cloud Foundry, plus précisément au Swisscom Application Cloud.Cloud Foundry L'instance de site Web PHP se bloque avec la configuration mime personnalisée

Ceci est mon fichier que source, situé à ${APP_ROOT}/www/index.html

<html> 
<?php 
    phpinfo(); 
?> 
</html> 

Mes fichiers de configuration sont les suivantes.

A .bp-config/options.json:

{ 
    "WEBDIR": "www", 
    "PHP_VERSION": "{PHP_56_LATEST}", 
    "WEB_SERVER": "httpd" 
} 

A .bp-config/httpd/httpd.conf:

ServerRoot "${HOME}/httpd" 
Listen ${PORT} 
ServerAdmin "${HTTPD_SERVER_ADMIN}" 
ServerName sample-app.scapp.io 
DocumentRoot "${HOME}/#{WEBDIR}" 
Include conf/extra/httpd-modules.conf 
Include conf/extra/httpd-mime.conf 

Le nom du serveur que je prends de l'installation dans le Swisscom App Cloud: enter image description here

A .bp-config/httpd/extra/httpd-modules.conf:

LoadModule mpm_event_module modules/mod_mpm_event.so 

Cela semble être requis selon les journaux d'erreurs, s'ils ne sont pas inclus.

A .bp-config/httpd/extra/httpd-mime.conf:

<IfModule mime_module> 
    AddType application/x-httpd-php .php .htm .html 
</IfModule> 

Le code source ci-dessus peuvent être consultées pour plus de commodité à this GitHub repo.

L'instance ne peut pas être démarrée mais je ne trouve aucun message d'erreur descriptif. Ce sont les journaux de la Swisscom application Cloud:

2017-05-19 12:56:26 [API/1] OUT Created app with guid 383e1568-29e9-4ef5-9825-3e1248a85b8e 
2017-05-19 12:56:28 [API/3] OUT Updated app with guid 383e1568-29e9-4ef5-9825-3e1248a85b8e ({"route"=>"025e8337-7fd2-42c8-a325-d535af3db460", :verb=>"add", :relation=>"routes", :related_guid=>"025e8337-7fd2-42c8-a325-d535af3db460"}) 
2017-05-19 12:56:38 [API/1] OUT Updated app with guid 383e1568-29e9-4ef5-9825-3e1248a85b8e ({"state"=>"STARTED"}) 
2017-05-19 12:56:38 [STG/0] OUT Downloading dotnet_core_buildpack... 
2017-05-19 12:56:38 [STG/0] OUT Downloading nodejs_buildpack... 
2017-05-19 12:56:38 [STG/0] OUT Downloading python_buildpack... 
2017-05-19 12:56:38 [STG/0] OUT Downloading binary_buildpack... 
2017-05-19 12:56:38 [STG/0] OUT Downloading go_buildpack... 
2017-05-19 12:56:39 [STG/0] OUT Downloaded nodejs_buildpack 
2017-05-19 12:56:39 [STG/0] OUT Downloading php_buildpack... 
2017-05-19 12:56:39 [STG/0] OUT Downloaded dotnet_core_buildpack 
2017-05-19 12:56:39 [STG/0] OUT Downloading java_buildpack... 
2017-05-19 12:56:39 [STG/0] OUT Downloaded binary_buildpack 
2017-05-19 12:56:39 [STG/0] OUT Downloading staticfile_buildpack... 
2017-05-19 12:56:39 [STG/0] OUT Downloaded python_buildpack 
2017-05-19 12:56:39 [STG/0] OUT Downloading ruby_buildpack... 
2017-05-19 12:56:39 [STG/0] OUT Downloaded go_buildpack 
2017-05-19 12:56:39 [STG/0] OUT Downloaded java_buildpack 
2017-05-19 12:56:39 [STG/0] OUT Downloaded php_buildpack 
2017-05-19 12:56:39 [STG/0] OUT Downloaded staticfile_buildpack 
2017-05-19 12:56:39 [STG/0] OUT Downloaded ruby_buildpack 
2017-05-19 12:56:39 [STG/0] OUT Creating container 
2017-05-19 12:56:39 [STG/0] OUT Successfully created container 
2017-05-19 12:56:39 [STG/0] OUT Downloading app package... 
2017-05-19 12:56:39 [STG/0] OUT Downloaded app package (1.5K) 
2017-05-19 12:56:39 [STG/0] OUT Staging... 
2017-05-19 12:56:41 [STG/0] OUT -------> Buildpack version 4.3.31 
2017-05-19 12:56:41 [STG/0] OUT Installing HTTPD 
2017-05-19 12:56:41 [STG/0] OUT HTTPD 2.4.25 
2017-05-19 12:56:42 [STG/0] OUT Downloaded [file:///tmp/buildpacks/d16e91f150d8c31f69507a615bf75f08/dependencies/https___buildpacks.cloudfoundry.org_dependencies_httpd_httpd-2.4.25-linux-x64-bf8851c4.tgz] to [/tmp] 
2017-05-19 12:56:42 [STG/0] OUT Installing PHP 
2017-05-19 12:56:42 [STG/0] OUT PHP 5.6.30 
2017-05-19 12:56:42 [STG/0] OUT Downloaded [file:///tmp/buildpacks/d16e91f150d8c31f69507a615bf75f08/dependencies/https___buildpacks.cloudfoundry.org_dependencies_php_php-5.6.30-linux-x64-13625eaa.tgz] to [/tmp] 
2017-05-19 12:56:44 [STG/0] OUT Finished: [2017-05-19 10:56:44.679464] 
2017-05-19 12:56:53 [STG/0] OUT Exit status 0 
2017-05-19 12:56:53 [STG/0] OUT Staging complete 
2017-05-19 12:56:53 [STG/0] OUT Uploading droplet, build artifacts cache... 
2017-05-19 12:56:53 [STG/0] OUT Uploading droplet... 
2017-05-19 12:56:53 [STG/0] OUT Uploading build artifacts cache... 
2017-05-19 12:56:53 [STG/0] OUT Uploaded build artifacts cache (198B) 
2017-05-19 12:57:01 [STG/0] OUT Uploaded droplet (55.3M) 
2017-05-19 12:57:01 [STG/0] OUT Uploading complete 
2017-05-19 12:57:01 [STG/0] OUT Destroying container 
2017-05-19 12:57:02 [CELL/0] OUT Creating container 
2017-05-19 12:57:02 [CELL/0] OUT Successfully created container 
2017-05-19 12:57:04 [STG/0] OUT Successfully destroyed container 
2017-05-19 12:57:06 [CELL/0] OUT Starting health monitoring of container 
2017-05-19 12:57:07 [APP/PROC/WEB/0] OUT 10:57:07 php-fpm | [19-May-2017 10:57:07] NOTICE: fpm is running, pid 40 
2017-05-19 12:57:07 [APP/PROC/WEB/0] OUT 10:57:07 php-fpm | [19-May-2017 10:57:07] NOTICE: ready to handle connections 
2017-05-19 12:57:07 [APP/PROC/WEB/0] OUT Exit status 1 
2017-05-19 12:57:07 [CELL/0] OUT Exit status 0 
2017-05-19 12:57:07 [CELL/0] OUT Destroying container 
2017-05-19 12:57:07 [API/3] OUT Process has crashed with type: "web" 
2017-05-19 12:57:07 [API/3] OUT App instance exited with guid 383e1568-29e9-4ef5-9825-3e1248a85b8e payload: {"instance"=>"", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"2 error(s) occurred:\n\n* 2 error(s) occurred:\n\n* Exited with status 1\n* cancelled\n* cancelled", "crash_count"=>1, "crash_timestamp"=>1495191427514377386, "version"=>"ede7276b-e0a6-467c-a86a-5c60f1c36021"} 

Je suppose qu'il doit y avoir d'autres journaux avec plus d'informations sur l'accident, mais je ne sais pas où les trouver.

Quelle est la cause de l'accident et comment puis-je le réparer?

Répondre

2

Je ne suis pas sûr de savoir pourquoi votre application échoue. Ma conjecture est que HTTPD n'aime pas la configuration et il se termine. Il n'y a pas de sortie de HTTPD dans le journal et vous devriez le voir démarrer, comme ceci.

Ex:

2017-05-20T08:26:18.76-0400 [APP/PROC/WEB/0] OUT 12:26:18 httpd | [Sat May 20 12:26:18.741822 2017] [mpm_event:notice] [pid 103:tid 140440543442816] AH00489: Apache/2.4.25 (Unix) configured -- resuming normal operations 
2017-05-20T08:26:18.77-0400 [APP/PROC/WEB/0] OUT 12:26:18 httpd | [Sat May 20 12:26:18.741947 2017] [mpm_event:info] [pid 103:tid 140440543442816] AH00490: Server built: Dec 20 2016 22:27:46 
2017-05-20T08:26:18.77-0400 [APP/PROC/WEB/0] OUT 12:26:18 httpd | [Sat May 20 12:26:18.741961 2017] [core:notice] [pid 103:tid 140440543442816] AH00094: Command line: '/app/httpd/bin/httpd -f /home/vcap/app/httpd/conf/httpd.conf -D FOREGROUND' 

Si vous voulez avoir procédé PHP-FPM vos fichiers HTML que vous devez faire un changement de couple.

1.) Dans .bp-config/httpd/extra/httpd-php.conf, vous devez modifier ou ajouter le bloc <Directory "${HOME}/#{WEBDIR}"> de sorte qu'il envoie des fichiers .html à PHP-FPM. Si vous ne le faites pas, httpd va tout simplement les servir ou retourner un 404.

Ex: qui envoie à la fois .php & .html

<Directory "${HOME}/#{WEBDIR}"> 
    <Files *.php> 
     <If "-f %{REQUEST_FILENAME}"> # make sure the file exists so that if not, Apache will show its 404 page and not FPM 
      SetHandler proxy:fcgi://#{PHP_FPM_LISTEN} 
     </If> 
    </Files> 
    <Files *.html> 
     <If "-f %{REQUEST_FILENAME}"> # make sure the file exists so that if not, Apache will show its 404 page and not FPM 
      SetHandler proxy:fcgi://#{PHP_FPM_LISTEN} 
     </If> 
    </Files> 
</Directory> 

2.) Vous devez demander à PHP-FPM pour traiter fichiers avec une extension .html. Il ne le fait pas par défaut car il tente d'empêcher les abus en raison d'une mauvaise configuration (c'est-à-dire empêche un attaquant d'évaluer un fichier avec une extension inattendue).

Pour ce faire, vous devez ajouter le fichier .bp-config/php/fpm.d/php-process-html.conf (la partie php-process-html n'a pas d'importance, mais le nom doit se terminer par .conf). A l'intérieur, vous avez besoin de mettre les éléments suivants:

[www] 
security.limit_extensions = .php .html 

Cela indique PHP-FPM pour traiter les fichiers .php et .html.

Remarque: cela nécessite au moins la version 4.3.32 du pack de construction PHP, ce qui est assez nouveau pour moi d'écrire ceci. Si vous utilisez une ancienne version du build pack, c'est toujours possible mais vous devez fournir un fichier de configuration php-fpm.conf personnalisé complet au lieu de remplacer cette seule propriété et ce fichier entrerait dans .bp-config/php/php-fpm.conf. Prenez l'un des fichiers php-fpm.conf de here et utilisez-le comme base pour commencer si vous êtes bloqué sur un ancien build pack.

+0

J'ai copié la [config entière par défaut] (https://github.com/cloudfoundry/php-buildpack/tree/master/defaults/config) et cela a résolu le problème de plantage mais je ne peux toujours pas appliquer votre config réussi: 'Got error 'L'accès au script' /home/vcap/app/www/index.html 'a été refusé (voir security.limit_extensions)'. Les dernières modifications sont [ici] (https://github.com/atineoSE/sample-php-app-cloudfoundry). – atineoSE

+0

Pour l'anecdote, la version du build pack php est 4.3.31, donc j'utilise l'approche pour copier l'ensemble du fichier 'php-fpm.conf' – atineoSE

+0

Vous devez définir' security.limit_extensions' comme dans l'exemple ci-dessus. Le fichier par défaut l'a mis en commentaire, alors décommentez-le et définissez la liste sur '.php .html'. Pour ce que ça vaut, n'incluez pas de fichiers de configuration avec votre application que vous ne surchargez pas. Cela permet au build build de fournir les valeurs par défaut. Je vois que vous avez aussi 'php.ini'. Vous voulez juste le fichier que vous remplacez. –