简体   繁体   English

Google App Engine 上 Codeigniter 站点的路由

[英]Routing for Codeigniter site on Google App Engine

I am trying to deploy a Codeigniter site to Googe App Engine PHP 7. The site includes a contact form plugin that exists in the data folder outside the Application folder like this:我正在尝试将 Codeigniter 站点部署到 Googe App Engine PHP 7。该站点包含一个联系表单插件,该插件存在于 Application 文件夹外的data文件夹中,如下所示:

Root
--application
--data
--css
--js
--system

When I access this page from the Cloud Shell localhost, it loads perfectly:当我从 Cloud Shell localhost 访问此页面时,它完美加载:

https://8080-dot-1234567-dot-devshell.appspot.com/data/contact.php

But after I deploy this site to Google App Engine and try to access the page, it returns a 404 Not Found error:但是在我将此站点部署到 Google App Engine 并尝试访问该页面后,它返回404 Not Found错误:

https://mysite.appspot.com/data/contact.php

Can someone explain why the page works over localhost but not when deployed to Google App Engine?有人可以解释为什么该页面可以在 localhost 上运行,但在部署到 Google App Engine 时却不能吗?

The location of the app.yaml file is crucial in such cases: the directory in which this file is located is considered the top level of your application.在这种情况下, app.yaml文件的位置至关重要:该文件所在的目录被视为应用程序的顶层。 Which has 2 main implications:这有两个主要含义:

  • all artifacts needed by the application must be located somewhere inside this app top level directory, the app deployment process won't look outside it.应用程序所需的所有工件都必须位于此应用程序顶级目录内的某个位置,应用程序部署过程不会在其外部查看。 I suspect this to be your case - if your app.yaml file is inside the application dir and the data dir being outside it.我怀疑这是你的情况 - 如果你的app.yaml文件在application目录内而data目录在它之外。 It might be possible to work around this by symlink-ing the necessary artifacts/directories from outside the top level dir to inside it (see How to upload a Google App Engine (Go) project in a different folder than the app.yaml ), but that doesn't work for all runtimes.可以通过将必要的工件/目录从顶级目录外部符号链接到内部来解决此问题(请参阅如何在与 app.yaml 不同的文件夹中上传 Google App Engine (Go) 项目),但这并不适用于所有运行时。
  • the paths for accessing artifacts in your app need to be relative to the app top level directory.访问应用程序中工件的路径需要相对于应用程序顶级目录。

The development server for some runtimes includes checks for these (making your app behave closer to how it will behave when deployed on GAE) but not all runtimes have this (and some don't even have a dedicated development server), leaving room for such discrepancies between the live and development app.某些运行时的开发服务器包括对这些的检查(使您的应用程序的行为更接近它在 GAE 上部署时的行为方式)但并非所有运行时都具有此功能(有些甚至没有专用的开发服务器),为此类留出空间实时应用程序和开发应用程序之间的差异。

Note: what's referred to by "application" in this context is really a GAE service/module (they're the same in the case of single service app).注意:在这种情况下,“应用程序”所指的实际上是一个 GAE 服务/模块(它们在单服务应用程序的情况下是相同的)。 But in the case of a GAE app with multiple services all these considerations need to be applied to each app service.但是对于具有多个服务的 GAE 应用程序,所有这些考虑都需要应用于每个应用程序服务。 Potentially of interest for such case: Can a default service/module in a Google App Engine app be a sibling of a non-default one in terms of folder structure?对这种情况的潜在兴趣: 就文件夹结构而言,Google App Engine 应用程序中的默认服务/模块可以是非默认服务/模块的同级吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM