My app was working fine in php55 using the below app.yaml settings to grouped URLs. E.G. /api/manage, /api/edit, api/user/add should all be forwarded to /api/api.php but stopped working when upgraded to php72.
Fine below the app.yaml conifig for both php55 and php72 for your help.
Configuration for php55
service: default
runtime: php55
handlers:
- url: /api((/$)|(/[^/]+(/$)?)*)
script: /api/api.php
secure: always
Configuration for php72
service: default
runtime: php72
handlers:
- url: /api/(.*?)/(.*)
script: /api/api.php
secure: always
Thanks in advance.
For the 2nd generation runtimes (including PHP 7+) you no longer use the script element to route traffic (documentation). You have to use a language idiomatic web/routing framework (e.g. Flask in Python, a front controller for PHP).
Related
I have already deployed on Google App Engine default service in PHP, but I need to create another service to enable me redirect to the mobile version of my website from example.com to mobile.example.com.
I read on google docs that you use I AM ADMIN, I have done the suggested method but to no avail.
Please kindly point me to the way. Thanks in advance.
I just figured it out. The solution was in the app.yaml file, add the service:service_name in the app.yaml if it is not created, it would create it automatically.
runtime: php72
runtime_config:
document_root:
handlers:
- url: /.*
script: auto
secure: always
redirect_http_response_code: 301
entrypoint:
serve worker.php
TO
runtime: php72
runtime_config:
document_root:
handlers:
- url: /.*
script: auto
secure: always
redirect_http_response_code: 301
entrypoint:
serve worker.php
service: mobile-frontend
Good day,
Problem
I have been trying to deploy my local PHP Code that is hosted in GitLab using Google Cloud Platform for my Kubernetes. I have managed to link the project to Kubernetes but I'm failing to deploy it to production as I have little or no knowledge on how to use .yml configs.
Tried Solutions and Code
.gitlab-ci.yml
image: google/cloud-sdk:alpine
deploy_production:
stage: deploy
environment: Production
only:
- master
script:
- echo $SERVICE_ACCOUNT > /tmp/$CI_PIPELINE_ID.json
- gcloud auth activate-service-account --key-file /tmp/$CI_PIPELINE_ID.json
- gcloud --quiet --project $PROJECT_ID app deploy app.yaml dispatch.yaml
after_script:
- rm /tmp/$CI_PIPELINE_ID.json
app.yaml
runtime: php73 # Replace with php73 to use the PHP 7.3 runtime
handlers:
# Serve a directory as a static resource.
- url: /stylesheets
static_dir: stylesheets
secure: always
# Serve images as static resources.
- url: /(.+\.(gif|png|jpg))$
static_files: \1
upload: .+\.(gif|png|jpg)$
# Serve your app through a front controller at index.php or public/index.php.
- url: .*
script: auto
dispatch.yaml
dispatch:
- url: "example.com/*"
service: default
Outcome Trying to achieve
So what I am trying to archive for starters is for production to install PHP with all dependencies, have an app staging, production stage and specifying the domain I want to serve the application at.
Recommendations are highly welcome
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!
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