简体   繁体   English

如何从Google App Engine标准上的CI应用程序的子目录获取自定义php应用程序运行?

[英]How to get a custom php application run from a subdirectory of a CI application on Google App Engine Standard?

I am a bit confused about how to set the app.yaml up in order to get my work done. 我对如何设置app.yaml以便完成工作感到有些困惑。 Previously I had this same codeigniter application running elsewhere with /support sub-directory serving a custom php support desk application. 以前,我有相同的codeigniter应用程序在其他地方运行,其中/support子目录为自定义php支持平台应用程序提供服务。 It had no issues. 没有问题。 Good ol' apache served it without any issue. 好的apache服务没有任何问题。

Now I want the same thing to be working on GAE! 现在,我希望在GAE上进行同样的工作! This is my app.yaml 这是我的app.yaml

application: <NAME>
version: 1
runtime: php55
api_version: 1
threadsafe: yes

handlers:

- url: /assets
  static_dir: assets

- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: /support/.*
  script: index.php

- url: /.*
  script: index.php
  secure: always

Just to make sure that I get all the files routed correctly after someone provides me a solution. 只是为了确保在有人为我提供解决方案后,我能正确路由所有文件。 Here's the directory structure for the support desk (It's called hesk)- 这是服务台的目录结构(称为hesk)-

在此处输入图片说明

I need a solution with wildcards so that /support works flawlessly with the sub-folders & everything.. also need to define static files. 我需要一个带有通配符的解决方案,以便/support可以完美地与子文件夹及其他所有组件一起使用。.还需要定义静态文件。 as you can see they are scattered all over the place.. not at all convenient but that's how it is! 如您所见,它们分散在各处。.根本不方便,但是就是这样! am poor at regex. 在正则表达式方面很差。 So please have mercy on me. 所以,请怜悯我。

Update: I added updated the app.yaml a bit.. now all the php scripts from the support root & 1st level sub-directories work 更新:我添加了对app.yaml的更新。.现在,所有支持根目录和1级子目录的php脚本都可以工作

- url: /support/(.*)/(.*)\.php$
  script: support/\1/\2.php

- url: /support/(.*)\.php$
  script: support/\1.php

But problem is there are a tons of sub-folders in this thing. 但是问题在于,这东西有很多子文件夹。 see this snap below of the support/inc folder. 请参阅以下support / inc文件夹中的快照。 how to handle that? 如何处理? do I have to manually put a url-script pair for all the possible number of sub-dir levels? 我是否必须为所有可能的子目录级别数手动放置一个url-脚本对? This is so frustrating! 真令人沮丧!

在此处输入图片说明

You are sending every call to - url: /support/.* to index.php . 您正在将每个呼叫发送到index.php - url: /support/.* index.php What you want is a regex to send to the proper script: 您想要的是将正则表达式发送到正确的脚本:

- url: /support/(.+).php
  script: support/\1.php

NOTE: your app.yaml and index.php are located inside the support directory. 注意:您的app.yamlindex.php位于support目录内。 You will want app.yaml at the root, or you won't be able to access files outside the support dir. 您将需要app.yaml作为根目录,否则将无法访问支持目录以外的文件。 Is support the root of this application? support是该应用程序的根吗?

Remember: urls are relative to the app.yaml file 请记住:网址是相对于app.yaml文件的

For files at the root level, you would use: 对于根级别的文件,可以使用:

- url: /(.+).php
  script: \1.php

You will want to put your static files in a static directory, and use: 您将需要将静态文件放在静态目录中,并使用:

- url: /static
  static_dir: static

and access the files using, eg: /static/hesk_javascript.js 并使用以下文件访问文件: /static/hesk_javascript.js

UPDATE 2 To handle static files using regex: 更新2使用正则表达式处理静态文件:

- url: /support/(.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg))$
  static_files: support/\1
  upload: support/.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg)$
  application_readable: true

Solution : Thanks GAEfan.. I kinda mixed n matched from your ideas & finally these are the needed handlers. 解决方案:谢谢GAEfan ..我有点混合了您的想法,最后才是所需的处理程序。 It's running perfectly now! 现在运行完美!

#for all the static files residing at support root or at any other level
- url: /support/(.*\.(htm$|css$|js$|ico$|jpg$|png$|gif$))$
  static_files: support/\1
  upload: support/.*\.(htm$|css$|js$|ico$|jpg$|png$|gif$)$
  application_readable: true

#for all the php files running at support root or at any other level
- url: /support/(.+)\.php
  script: support/\1.php

#for using index.php at support root or at any other level
- url: /support/(.*)
  script: support/\1/index.php

PS : the handler below can run index.php from any other level but not support root PS:下面的处理程序可以从任何其他级别运行index.php,但不支持root

- url: /support/(.+)
  script: support/\1/index.php

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

相关问题 如何将php应用程序从本地计算机部署到Google App Engine - How to deploy a php application from local machine to google app engine 如何使此CI php应用程序从本地计算机运行 - How do I get this CI php application to run from my local machine 从PHP应用程序使用Google Cloud Storage(不在App Engine上托管) - Use Google Cloud Storage from PHP application (not hosted on App Engine) 如何将我的PHP应用程序部署到Google App Engine? - How to deploy my PHP application to Google App Engine? 如何查看文件部署到Google App Engine的php应用程序 - How to view files a php application deployed to google app engine 部署后如何在 Google App Engine Standard 上运行 Laravel 迁移 - How to run Laravel migrations on Google App Engine Standard after Deployment 如何通过 PHP App Engine 应用程序在 Google Compute Engine 实例上创建 cron 作业? - How to create a cron job on a Google Compute Engine instance via a PHP App Engine application? 如何在 Google App Engine 上运行 php 脚本? - How to run php script on Google App Engine? Google App Engine上的codeigniter应用程序 - codeigniter application on google app engine Google App Engine应用拥有的驱动器API(PHP) - Google App Engine Application-Owned Drive API (PHP)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM