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