Google App Engine dispatch.yaml Validation error PHP module - php

I have the following error when I update dispatch.yaml.
Error 400: --- begin server output ---
Validation error: Invalid dispatch configuration - module 'redirect' does not exist. Upload a version of this module and try again.
--- end server output ---
app.yaml
application: test
module: default
version: 1-1
runtime: php55
api_version: 1
threadsafe: yes
handlers:
- url: /(.*)
static_files: index.html
upload: index.html
redirect.yaml
application: test
module: redirect
version: 1-1
runtime: php55
api_version: 1
threadsafe: yes
handlers:
- url: /
script: routing.php
dispatch.yaml
dispatch:
- url: "example.com/"
module: redirect
- url: "/*"
module: default
Could I fix it?

When you run appcfg.py update on a folder only the default module specified by app.yaml will be uploaded. You need to specify any additional modules you want to upload separately.

Related

Hosting a static website on Google App Engine using a PHP form

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

Web app bad format in google app engine

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.

Google App Engine - Separate Project Required?

I'm trying to port a simple website across to the Google App Engine. My website uses PHP and accesses a MySQL database.
In the App engine I've created a project, e.g.: my-project.
Then within that project I did what I was told, to get a MySQL database up and running: create a SQL instance, download phpMyAdmin locally, create app.yaml file:
application: my-project
version: 1
module: default
runtime: php55
api_version: 1
handlers:
- url: /(.*\.(ico$|jpg$|png$|gif$))
static_files: \1
upload: (.*\.(ico$|jpg$|png$|gif$))
application_readable: true
- url: /(.*\.(htm$|html$|css$|js$))
static_files: \1
upload: (.*\.(htm$|html$|css$|js$))
application_readable: true
- url: /(.*\.(php$))
script: \1
login: admin
- url: /(.+)
script: index.php
login: admin
- url: /.*
script: index.php
login: admin
I then deployed the app and went to
https://phpmyadmin-dot-my-project.appspot.com
phpMyAdmin worked perfectly.
Next, I created followed the helloworld.php example:
https://cloud.google.com/appengine/docs/php/gettingstarted/helloworld
Again, that worked, with the PHP code executing on the server to display 'Hello world!'.
Finally, I went back to:
https://phpmyadmin-dot-my-project.appspot.com
but no dice, it just displays 'Hello world!'.
Must be something very basic that I'm missing, do I need to create a separate project for each?
E.g.:
1. create project with MySQL DB instance and phpMyAdmin
2. create project with the PHP files
In the app.yaml for phpmyadmin, I needed to change:
module: default to module: phpmyadmin
application: myapp-beta
version: 1
module: phpmyadmin
runtime: php55
api_version: 1
Same for the app.yaml file for helloworld. Just created a new module called helloworld.
Need to read up on YAML and modules... thanks!

Google Apps Engine PHP - how to hide included scripts

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

How to get my application to work on appengine

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.

Categories