I have deployed several PHP apps on GAE standard environment, all working fine.
Now I'm deploying a new app, which on the local server provided by the gcloud
SDK works as expected (terminal command: dev_appserver.py --log_level=warning app.yaml
).
The problem is that when I deploy it to the live GAE service (gcloud app deploy app.yaml --project myapp
), I get a 404 error message:
The page could not be found
No web page found for the web address: xxx
HTTP ERROR 404
The app.yaml looks like this:
runtime: php55
api_version: 1
threadsafe: true
skip_files:
- README.md
- package.json
handlers:
- url: /(.*\.html)
script: mod_rewrite.php
secure: always
- url: /(.*\..{2,})
static_files: \1
upload: (.*\..{2,})
secure: always
- url: /.*
script: mod_rewrite.php
secure: always
I'va also tried to add a test handler pointing to a specific file:
- url: /(mytest\.html)
static_files: \1
upload: mytest.html
secure: always
In this way I was able to reach the url. But that was it. Any other url is 404.
An interesting thing is that on the Versions
tab of the GAE app in the current deployed version it states that the app is 0 B
, even if there are no previous versions of it, while it should be around 30 Mb. When deploying, all 988 files seems to be uploaded, also because due to my slow internet connection it takes a while.
I have tried to redeploy the whole thing to a new project, after successfully completing the tutorial, and I still encounter the same problem.
You can use the
application_readable
handler option to include the respective static files in the app code as well. From Handlers element:Like this:
After several hours of testing, I finally realized what the problem was.
In GAE when declaring a certain path static, it is then interpreted as a non-code path. All files within that path are therefore not accessible by the scripts running on the PHP environment with
require
orinclude
and they are not shown in the deployed code debugger.For this reason, I have placed all static files in a sub-folder (
www
), and non static files to berequired
by PHP scripts under another subfolder.