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!
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.
This is my app.yaml file:
application: xxxxxxxxxxxxx
version: 1
runtime: php55
api_version: 1
threadsafe: true
handlers:
- url: /images
static_dir: images
- url: /css
static_dir: css
- url: /js
static_dir: js
- url: /libraries
static_dir: libraries
- url: /
script: main.php
# Serve php scripts.
- url: /(.+\.php)$
script: \1
This is the error I get:
Error 400: --- begin server output ---
PHP 5.4 applications are prevented from being deployed to Google App Engine from any version of the SDK, including older ones. If you need to continue to deploy PHP 5.4 applications for compatibility reasons, you can request that your application be whitelisted for PHP 5.4 deployment by visiting http://goo.gl/qjKEuk.
--- end server output ---
Can somebody please tell me why I still get this error after changing runtime from php to php55 in app.yaml?
You need to update your Google App Engine Launcher to 1.9.18 or higher. You can't use php55 with 1.9.17 (and I just updated to 1.9.20 and it is a bit different, uses your browser to log in).
PhpStorm plugin is still not compatible with deploying php55 apps. Deploying through Google App Engine Launcher works fine.
I am trying to upload this as my app.yaml
application: *******
version: 2
runtime: php55
api_version: 1
threadsafe: yes
instance_class: F2
automatic_scaling:
min_idle_instances: 1
max_idle_instances: 5
min_pending_latency: 5.0s
max_pending_latency: 7.7s
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /resources
static_dir: resources
- url: /static
static_dir: static
- url: /test.php
script: test.php
- url: .*
script: home/service/index.php
How ever every time I do upload it, it says I am using custom peformance settings and to look at the application section. This is the exact error I get Your application currently has custom performance settings that are not compatible with the Modules feature. You must either clear or migrate these application-level settings before you can upload a non-default module. See the Performance section of the Application Settings page of the Admin Console for more information.
So I looked at the migrate to app section and here is what it says.
application: ********
# Other settings here...
instance_class: F2
automatic_scaling:
min_idle_instances: 1
max_idle_instances: 5
min_pending_latency: 5.0s
max_pending_latency: 7.7s
I've followed the guides as close as possible, I am not sure what is wrong with my app.yaml? I have removed all the other .yaml files (I had a pdf.yaml [module] and a dispatch.yaml) it all booted up fine on the local dev machine but when I call appcfg.py update app.yaml - I just get told of my issue with custom performance settings, any help would be much appreciated
It's funny every time I post to Stackoverflow, I always find a solution soon after (I've been trying to solve this issue for days btw)
You have to set all the application settings to Automatic on the Old-Settings page, and suddenly modules work.
Cheers
I am trying to install phpMyAdmin utilizing the PHP SDK kit. I am getting this phpMyAdmin error in my local test environment:
The mysqli extension is missing. Please check your PHP configuration.
Anyone have any recommendations for the app.yaml file that would work best with phpMyAdmin and google app engine utilizing PHP?
This worked for me -
application: phpmyadmin
version: pn
runtime: php
api_version: 1
handlers:
- url: /(.+\.php)
script: phpmyadmin/\1
- url: /(.+\.php)\?.+$
script: phpmyadmin/\1
- url: /
script: phpmyadmin/index.php
- url: /(.*\.(htm$|html$|css$|js$|ico$|jpg$|png$|gif$))
static_files: phpmyadmin/\1
upload: phpmyadmin/(.*\.(htm$|html$|css$|js$|ico$|jpg$|png$|gif$))
application_readable: true