【问题标题】:Google App Engine Deployment Issue When Switching Environments切换环境时的 Google App Engine 部署问题
【发布时间】:2023-04-05 01:20:01
【问题描述】:

当我将 app.yaml 文件设置为部署在 flex 环境中时,一切正常。

runtime: php
env: flex

runtime_config:
  document_root: web

当我将 app.yaml 文件更改为在标准环境中部署时,出现 500 服务器错误。

runtime: php74
env: standard

runtime_config:
  document_root: web

yaml文件在运行标准环境时是否需要额外的参数?

答案见下文。

【问题讨论】:

    标签: php google-app-engine yaml


    【解决方案1】:

    app.yaml docs for PHP5PHP7 没有为 PHP 标准环境列出 runtime_config 的条目

    如果您查看hello world 应用程序的official samples,您会注意到只有flex 环境有它。 standard 没有

    【讨论】:

    • 即使保留 runtime_config 一切正常。我没有收到错误,所以我没有考虑删除它。我认为无论环境如何,这是一个要求。我是新人,所以我还在学习。现在我很清楚,使用 flex 可以使用 runtime_config 定义包含 index.php 的主文件夹,但使用标准可以定义 index.php 的入口点 - 对我来说似乎是多余的,但如果谷歌这样做了,我确信这是有原因的.
    【解决方案2】:

    对于标准环境https://cloud.google.com/appengine/docs/standard/php7/runtime 声明:您将需要部署一个前端控制器来处理所有请求路由。如果您的应用包含 public/index.php 或 index.php 文件,App Engine 将使用此文件为您的应用提供服务。

    对我来说,这读作“如果您的根目录中有一个 index.php,无论目录如何,它都可以工作,而无需在 app.yaml 文件中定义入口点”,但事实并非如此。

    如果您的文件结构是 ap​​p>public>index.php,并且您想使用 index.php 作为前端控制器,那么您不必在 app.yaml 文件中定义入口点。

    如果你的文件结构是 ap​​p>web>index.php,就像我上面的例子,并且你想使用 index.php 作为你的入口点/控制器,你必须将 entrypoint: serve web/index.php 添加到你的 app.yaml 文件中,或者如果你想要使用controller.php,你必须分别添加entrypoint: serve web/controller.php

    在我看来,最好手动定义入口点,即使您使用标准的 public/index.php 结构。

    runtime: php74
    env: standard
    entrypoint: serve public/index.php
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-01-22
      • 1970-01-01
      • 2017-11-16
      • 1970-01-01
      • 1970-01-01
      • 2016-11-06
      • 1970-01-01
      相关资源
      最近更新 更多