简体   繁体   中英

How to Correctly Upload Files to Google App Engine with App.yaml

I'm new to Google App Engine and am encountering problems with my app.yaml file.

I have 5 .php files that run totally fine in one local directory on localhost, but have no clue how to set up my app.yaml.

When I gcloud app deploy , my index.php is loaded to the website, but only that is loaded and is causing issues due to includes and dependencies on the other files that my app.yaml is not uploading.

I have 5 files, index.php, connection.php, userpage.php, transit.php, and query.php

My test app.yaml to simply upload index.php and connection.php for testing is

# app.yaml
runtime: php55

handlers:
- url: /
    script: index.php

- url: /index\.html
    script: index.php 

- url: /
    script: connection.php

I need both to be in the same folder in google cloud's website to function properly, but only index.php is uploading.

By default, all the php files in the same root directory as the app.yaml file will be uploaded , you can see more information in that link. You can then import these files normally within your deployed app.

The problem in your app.yaml file is that you have two handlers (URL paths) linked to '/', so the second one will never be called. To fix this you can do:

# app.yaml
runtime: php55

handlers:
- url: /
    script: index.php

- url: /index\.html
  script: index.php 

- url: /connection
  script: connection.php

or

# app.yaml
runtime: php55

- url: /connection
  script: connection.php

- url: /.*
  script: index.php

In this example, if you add '/connection' at the end of the URL, the connection.php will be called.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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