I created a PHP web app which runs fine in localhost, but it is incorrectly formatted when I run it through GAE development server.
Do you have any idea why?
Correct format:
Incorrect format:
app.yaml:
runtime: php55
api_version: 1
handlers:
- url: /.*
script: index.php
You have to specify handlers for your static files so that they get uploaded with your deployed app:
runtime: php55
api_version: 1
handlers:
- url: /images
static_dir: images
- url: /css
static_dir: css
# Catch all handler for any other requests:
- url: /.*
script: index.php
Read more about using the static_dir or static_files options.
Related
I am hosting a simple HTML / CSS static website, that contains a php contact form, on Google App Engine. However, when the php Contact form is completed and submitted an error is generated, as it is not being run on the host. If I select the form directly it simply downloads, see https://firebellycomputing.com/forms/contact.php
Can anyone suggest a solution please?
My app.yaml is:
runtime: php72
handlers:
- url: /
static_files: spaqwebsite28apr2021/MyPortfolio-pro/index.html
upload: spaqwebsite28apr2021/MyPortfolio-pro/index.html
- url: /(.*)
static_files: spaqwebsite28apr2021/MyPortfolio-pro/\1
upload: spaqwebsite28apr2021/MyPortfolio-pro/(.*)
Based on your app.yaml you only serve static files for your application. Add script in handlers that will serve your all PHP files or specific PHP file, see the example below:
runtime: php55
api_version: 1
threadsafe: true
# Serve all php scripts from the root.
- url: /(.+\.php)$
script: \1
or
runtime: php55
api_version: 1
threadsafe: true
# Serve specific php scripts
- url: /contact.php
script: form_folder/contact.php
upload: form_folder/contact.php
I'm deploying a php app to GCP's app engine and can't make the app.yaml configuration work.
The app has this directory structure:
index.php
/sistema
/js
/images
/css
index.php
login.php
otherpage.php
...
I'm having problems with the pages that are under the 'sistemas' folder. And also would like to access those pages without the '.php' in the url.
I've tried with many handlers, but none of them worked as I wanted.
runtime: php55
threadsafe: yes
api_version: 1
handlers:
- url: /sistema/css/*
static_dir: sistema/css
- url: /sistema/js/*
static_dir: sistema/js
- url: /sistema/fonts/*
static_dir: sistema/fonts
- url: /sistema/images/*
static_dir: sistema/images
# Serve php scripts.
- url: /(.+\.php)$
script: \1
- url: /
script: index.php
lets say one have this index.php
<$php
include_once("dictionary.php");
...
$>
how must app.yaml be defined to upload "dictionary.php" but in a not exposed-way ? (the following example let users to browse http://mydomain/dictionary.php, which is what we want to avoid)
application: myGAEphpapp
version: 1
runtime: php
api_version: 1
threadsafe: yes
handlers:
- url: /
script: /index.php
- url: /dictionary\.php
script: /dictionary.php
The only way i found is to define the non-exposed scripts after a handle that gets all requests
application: myGAEphpapp
version: 1
runtime: php
api_version: 1
threadsafe: yes
handlers:
- url: /
script: /index.php
[...]
**- url: /.*
script: /catchall_script.php**
#never triggered but serverside available
- url: /dictionary.\php
script: /dictionary.php
I am using Google App Engine for the first time. I am trying to upload a CodeIgniter website, but the problem is no links in the website is working. Every link, even the css and js are going to the index page.
Here is my app.yaml:
application: vatiali-dev
version: 1
runtime: php
api_version: 1
threadsafe: false
handlers:
- url: /css
static_dir: css/
- url: /js
static_dir: js/
- url: /fonts
static_dir: fonts/
- url: /.*
script: index.php
You should change your app.yaml to look like this:
application: vatiali-dev
version: 1
runtime: php
api_version: 1
threadsafe: true
handlers:
- url: /css/*
static_dir: css
- url: /js/*
static_dir: js
- url: /fonts/*
static_dir: fonts
- url: /.*
script: index.php
I have also changed threadsafe to true, unless you had it set to false for a specific reason I believe it is best practice/standard to set it to true, or else you may get performance issues.
I developed a web application the usual way and hosted on a normal shared server.
These are what I mean by usual
Include my PHP function files (using php include/require)
Use my normal MySQL database with msqli
Upload my files normally to the server using FTP.
For some reasons, I need to move the web app to appengine, I have succeeded in uploading the files but it shows me this error:
500 Server Error
with this error in my log:
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 239, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 298, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 84, in LoadObject
obj = __import__(path[0])
ImportError: No module named index
What changes do I need to make to my files to enable my website work well on appengine without issues?
EDIT (Content of app.yaml)
application: gcdc2013-myworkset
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: .*
script: index.php
- url: /css
static_dir: stylesheets
- url: /images
static_dir: images
libraries:
- name: webapp2
version: "2.5.2"
I tried changing runtime to php but it gave an error which cleared immediately i changed it back to python27
EDIT:
Updated app.yaml file (Project deploys now but shows this error for all PHP files: Could not guess mimetype for excel/excel_reader.php. Using application/octet-stream.
Also the project appears as blank when viewed on the browser):
application: gcdc2013-myworkset
version: 1
runtime: php
api_version: 1
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: .*
script: index.php
- url: /
script: index.php
- url: /index\.php
script: index.php
- url: /features
script: features/index.php
- url: /about
script: about/index.php
- url: /oauth2callback/?
script: signup.php
- url: (.*)\.[\d]{10}\.(css|js)
static_files: $1.$2
upload: (.*).(.*)
- url: /css
static_dir: css
- url: /js
static_dir: js
Also, how can I import mysql database that I exported from my localhost to the appengine?
Change:
runtime: python27
To:
runtime: php
And remove:
libraries:
- name: webapp2
version: "2.5.2"
See https://developers.google.com/appengine/docs/php/config/appconfig for more information.