GAE PHP - image (.jpg) file not found on the server - php

My image file is not found on the server. I declared it as static on my app.yaml:
- url: /sampleimage\.jpg
static_files: sampleimage.jpg
upload: sampleimage\.jpg
As you can see it's on the root directory, I tested it first on localhost and it is found:
localhost:8080/sampleimage.jpg
However when deployed on the web it's not there:
http://samplesite.appspot.com/sampleimage.jpg
I don't know what I'm doing wrong here because my favicon.ico which is also static file is working fine http://samplesite.appspot.com/favicon.ico.
complete app.yaml:
application: samplesite
version: 1
runtime: php
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /
script: index.html
- url: /sampleimage\.jpg
static_files: sampleimage.jpg
upload: sampleimage\.jpg

Related

YAML rendering index.html every time any PHP is called on gCloud App Engine

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

CodeIgniter deploy in Google Cloud

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 deploy static files (html,css, js) and working good at gae but for php files gives 404 error

My app.yaml as:
runtime: php55
api_version: 1
threadsafe: true
handlers:
- url: /
static_files: www/index.html
upload: www/index.html
- url: /(.*)
static_files: www/\1
upload: www/(.*)
as seen above static files are under www dir. and php files are under the vendor dir and its sub sirs. I have read all days doc. to understand this yaml file to able to understand but unfortunately not yet :) . So, html and all static files works perfect. but when ajax calls php with sending data to php. gives 404 error. It works good on local wamp server. main opening page is index.html under www . And its ok. All day I tested many variant to able to deploy php files. Not able yet.
mainProjectRoot>app.yaml ( only this file and two directory "www and vendor")
www/index.html
/css
/js
vendor/smsgonder.php
/mail.php
/../../more php files
At least I gave up to try more variant and I need help to set up app.yaml page. (except above variant all extra code I received always error and no deployment)
Any help will be much appretiated. Thanks in advance !
final app.yaml is
runtime: php55
api_version: 2
threadsafe: true
handlers:
- url: /(.+\.php)$
script: vendor/\1
- url: /
static_files: www/index.html
upload: www/index.html
- url: /(.*)
static_files: www/\1
upload: www/(.*)
EDIT
this is final app.yaml ... (for a while I have deployed php files and some are were woring . But again for some php I receive "POST 500 error "
in case I like to share final app.yaml file here.
runtime: php55
api_version: 2
threadsafe: true
handlers:
- url: /(.*).php
script: \1.php
- url: /
static_files: www/index.html
upload: www/index.html
- url: /(.*)
static_files: www/\1
upload: www/(.*)
Any help will be very much appreciated. How could be :)) I spent 5-6 days just for deploying finished app :)'
add this immediately after handlers:
- url: /(.*)\.php$
script: vendor/\1.php
This will serve all request ending with .php to the php files within the vendor folder
The handlers section for PHP scripts following the documentation Example (works for vendor subdirectories as well):
# Serve php scripts.
- url: /(.+\.php)$
script: \1
Note: indentation matters!

wordpress in GAE wp-admin area css and js not loading

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).

php app update: Invalid character in filename

Problem when uploading php application which uses Wordpress
* version - 1.8.0
* language - php
* operating system - Windows 7
Update to the GAE shows the below error for many files. Tried renaming few files but the error pops for another file and so on. These are wordpress 3.5.1 files.
Error 400: --- begin server output ---
Invalid character in filename: __static__\wordpress/wp-includes/css/admin-bar.css
--- end server output ---
The app.yaml content:
-------------------------------------------
application: fargocricketclub
version: 1
runtime: php
api_version: 1
threadsafe: yes
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: /(.+)?/?
script: wordpress/index.php
I believe that this is fixed in the 1.8.1 release of App Engine, using the solution proposed above to join the path using the OS specific path separator.
Issue seen in PHP & Python 1.8.1 deployments on Windows when using application_readable. Issue flagged: https://code.google.com/p/googleappengine/issues/detail?id=9558
Work around:
replaced os.path.join with posixpath.join in google\appengine\tools\appcfg.py

Categories