I deployed a PHP application on Google App Engine, I tried different configurations of the app.yaml file and still can't get static files to be recognized.
Here is my code:
application: double-goal-88313
version: 1
runtime: php
api_version: 1
handlers:
- url: /Maps/stylesheet
static_dir: Maps/stylesheet
mime_type: 'text/css'
- url: /logodoc.png
static_dir: Maps/images/logodoc.png
application_readable: true
- url: /Maps/js
static_dir: Maps/js
mime_type: 'application/javascript'
- url: /findDoctor/.*
script: Maps/index.php
Thank you!
Looking at your comments in the above post you probably need something like
handlers:
- url: /Maps/stylesheet
static_dir: Maps/stylesheet
- url: /logodoc.png
static_files: Maps/images/logodoc.png
upload: Maps/images/logodoc.png
application_readable: true
- url: /Maps/js/(.*)
script: Maps/js/\1
- url: /findDoctor/(.*\.(htm|html|css|js))$
static_files: Maps/\1
upload: Maps/.*\.(htm|html|css|js)$
- url: /findDoctor/.*
script: Maps/index.php
First you can have a look at configuring app.yaml
then try
handlers:
- url: /Maps/stylesheet
static_dir: Maps/stylesheet
- url: /logodoc.png
static_files: Maps/images/logodoc.png
upload: Maps/images/logodoc.png
application_readable: true
- url: /Maps/js/(.*)
script: Maps/js/\1
- url: /findDoctor/.*
script: Maps/index.php
Now you can access
your-app-version.appspot.com/logodoc.png and your-app-version.appspot.com/Maps/js/file.js file.js should be inside js/file.js
Related
I'm using PHP55 to run a web-page on standard environment through Google App Engine. When I click the submit button on a form, it downloads the respective PHP code that should instead be executing. Here's my app.yaml:
runtime: php55
api_version: 1
threadsafe: true
handlers:
- url: /
static_files: www/index.html
upload: www/index.html
- url: /signUp.html
static_files: www/signUp.html
upload: www/signUp.html
- url: /submitEmail.php
static_files: www/submitEmail.php
upload: www/submitEmail.php
- url: /(.*)
static_files: www/\1
upload: www/(.*)
EDIT 1
So I initially tried the following for the handlers:
handlers:
-url: /(.+\.php)$
script: www/\1
-url: /
script: www/index.html
-url: /(.*)
script: www/\1
However this was in short - a disaster. Images and CSS didn't load after refreshing. All I want is for submitEmail.php to execute when the user clicks submit on the form in index.html.
To clarify this is my high-level structure:
www/
-index.html
-submitEmail.php
app.yaml
EDIT 2
Present state of app.yaml but when I submit the form I receive a 404 error.
handlers:
-url: /(.+\.php)$
script: www/\1
-url: /submitEmail.php
script: www/submitEmail.php
-url: /
script: www/index.html
-url: /(.*)
script: www/\1
Well the PHP code is delivered because you declared it as static_files. Static files are delivered as-is to the client when requested.
Change your handler like this:
- url: /submitEmail.php
script: www/submitEmail.php
upload: www/submitEmail.php
See also app.yaml reference.
I am learning how to move my existing PHP project to gCloud.
For the same, I created an AppEngine project and have placed my code there.
Everything seems to work except the PHP files.
When I launch my project, the index files launches (as specified in app.yaml) and then where the PHP should execute, it's renders the index.html file. This creates a deadly loop of index calling PHP calling index calling PHP :(
I am sure I have my app.yaml wrong, but am unable to figure out where the problem is.
My yaml looks like this:
runtime: php55
api_version: 1
threadsafe: true
handlers:
- url: /dialpad_research/(.*\.(appcache|manifest))
mime_type: text/cache-manifest
static_files: dialpad_research/static/\1
upload: dialpad_research/static/(.*\.(appcache|manifest))
- url: /dialpad_research/static
static_dir: dialpad_research/static
# image files
- url: /dialpad_research/static/(.*\.(bmp|gif|ico|jpeg|jpg|png))
static_files: static/\1
upload: static/(.*\.(bmp|gif|ico|jpeg|jpg|png))
# dialpad root
- url: /dialpad_research.*
static_files: dialpad_research/static/index.html
upload: dialpad_research/static/index.html
- url: /dialpad_research/api/(.+\.php)$
script: api/\1
Any help is appreciated.
Folder structure is like this:
Root
|
---- app.yaml
---- dialpad_research (folder)
|
---- static (folder with index file)
---- api (folder with PHP files)
You have to be careful with your regex matching. This url pattern:
- url: /dialpad_research/static
will match:
- url: /dialpad_research/static(anything to follow)
So, it will never get to the handler below:
- url: /dialpad_research/static/(.*\.(bmp|gif|ico|jpeg|jpg|png))
Same for:
- url: /dialpad_research.*
After that, it can never get to:
- url: /dialpad_research/api/(.+\.php)$
Reorder your handlers so that they don't short-circuit.
Next, /api/ and /static/ are not at the root so your paths to them are incorrect. See below:
handlers:
- url: /dialpad_research/(.*\.(appcache|manifest))
mime_type: text/cache-manifest
static_files: dialpad_research/static/\1
upload: dialpad_research/static/(.*\.(appcache|manifest))
# image files
- url: /dialpad_research/static/(.*\.(bmp|gif|ico|jpeg|jpg|png))
static_files: dialpad_research/static/\1
upload: dialpad_research/static/(.*\.(bmp|gif|ico|jpeg|jpg|png))
- url: /dialpad_research/api/(.+\.php)$
script: dialpad_research/api/\1
- url: /dialpad_research/static
static_dir: dialpad_research/static
# dialpad root
- url: /dialpad_research.*
static_files: dialpad_research/static/index.html
upload: dialpad_research/static/index.html
I have deployed CodeIgniter framework in Google Cloud app engine. But when I am trying to access website it is showing 404. I have attached screenshot of file structure .
Please help.
runtime: php55
threadsafe: yes
api_version: 1
handlers:
- url: /user_guide/
static_files: user_guide/index.html
upload: user_guide/index.html
- url: /user_guide/(.*)
static_files: user_guide/\1
upload: user_guide/(.*)
- url: /static/(.*)
static_files: static/\1
upload: static/(.*)
- url: .*
script: index.php
skip_files:
- ^(.*/)?#.*#$
- ^(.*/)?.*~$
- ^(.*/)?.*\.py[co]$
- ^(.*/)?.*/RCS/.*$
- ^(.*/)?\..*$
- ^(.*/)?.*\.bak$
I have installed wordpress in GAE. My wordpress installation has the popular Woocommerce plugin activated. The problem with this setup is that some of my fonts are not working. This is what I see :
The boxes should actually be stars. I am not sure, but I think this is happening because the mime type cant be guessed by GAE. In my browser console, I get the following messages
Resource interpreted as Image but transferred with MIME type
application/x-javascript:
this is my app.yaml:
application: XXXXXXX
version: 101
runtime: php
api_version: 1
handlers:
- url: /(.*\.(htm$|html$|css$|js$))
static_files: wordpress/\1
upload: wordpress/.*\.(htm$|html$|css$|js$)
application_readable: true
- url: /wp-content/(.*\.(ico$|jpg$|png$|gif$))
static_files: wordpress/wp-content/\1
upload: wordpress/wp-content/.*\.(ico$|jpg$|png$|gif$)
application_readable: true
- url: /(.*\.(ico$|jpg$|png$|gif$))
static_files: wordpress/\1
upload: wordpress/.*\.(ico$|jpg$|png$|gif$)
- url: /wp-admin/(.+)
script: wordpress/wp-admin/\1
secure: always
- url: /wp-admin/
script: wordpress/wp-admin/index.php
secure: always
- url: /wp-login.php
script: wordpress/wp-login.php
secure: always
- url: /wp-cron.php
script: wordpress/wp-cron.php
login: admin
- url: /xmlrpc.php
script: wordpress/xmlrpc.php
- url: /wp-(.+).php
script: wordpress/wp-\1.php
- url: /(.+)?/?
script: wordpress/index.php
- url: /(.*\.woff)
static_files: wordpress/\1
upload: wordpress/(.*\.woff)
mime_type: application/font-woff
- url: /(.*\.svg)
static_files: wordpress/\1
upload: wordpress/(.*\.svg)
mime_type: image/svg+xml
- url: /(.*\.eot)
static_files: wordpress/\1
upload: wordpress/(.*\.eot)
mime_type: application/vnd.ms-fontobject
- url: /(.*\.ttf)
static_files: wordpress/\1
upload: wordpress/(.*\.ttf)
mime_type: application/x-font-ttf
- url: /(.*\.otf)
static_files: wordpress/\1
upload: wordpress/(.*\.otf)
mime_type: application/x-font-otf
My limited (and possibly stale) experience with pagespeed suggests that you might consider disabling it until you have everything else working.
The only thing that jumps out is that the first two - url: stanzas in your app.yaml should be exchanged. These stanzas are consulted in order. /wp-content/foo.js will be matched by the more general first stanza, which looks like it isn't what you want. I doubt that's what's causing the mime type confusion, but turning off pagespeed should give you better info for further debugging.
I recently add wordpress to Google App Engine
Everything is working fine in the local PHP SDK
I used git it deploy the site to GAE, problem is in the live site admin area (wp-admin) one css and one js is not loading so I'm getting a display like this
I checked the missing resource they are
myappid.appspot../wp-admin/load-styles.php?c=0&dir=ltr&load=admin-bar,wp-admin,buttons,wp-auth-check&ver=3.6.1
and
myappid.appspot.../wp-admin/load-scripts.php?c=0&load%5B%5D=jquery-core,jquery-migrate,utils,json2&ver=3.6.1
These resources are loading fine in the local GAE PHP SDK. I'm using the same app.yaml that given in the google wordpress tutorial
I spend 2 days finding a solution for this Please help me out :)
This is my app.yaml file
application: entersys-wordpress
version: wp
runtime: php
api_version: 1
threadsafe: no
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /(.*\.(htm$|html$|css$|js$))
static_files: wordpress/\1
upload: wordpress/(.*\.(htm$|html$|css$|js$))
application_readable: true
- url: /wp-content/(.*\.(ico$|jpg$|png$|gif$))
static_files: wordpress/wp-content/\1
upload: wordpress/wp-content/(.*\.(ico$|jpg$|png$|gif$))
application_readable: true
- url: /(.*\.(ico$|jpg$|png$|gif$))
static_files: wordpress/\1
upload: wordpress/(.*\.(ico$|jpg$|png$|gif$))
- url: /wp-admin/(.+)
script: wordpress/wp-admin/\1
secure: always
- url: /wp-admin/
script: wordpress/wp-admin/index.php
secure: always
- url: /wp-login.php
script: wordpress/wp-login.php
secure: always
- url: /wp-cron.php
script: wordpress/wp-cron.php
login: admin
- url: /xmlrpc.php
script: wordpress/xmlrpc.php
- url: /(.+)?/?
script: wordpress/index.php
I think there is a bug if you use git to deploy not correctly pushing the static content.
I would try using the appcfg.py method to push your app to check (Follow Step 8 here).