Example 1: Using Cloud Shell in GCP Cloud console and existing project
## Enable Google App Engine Admin API
GCP Console -> APIs & Services -> Library
Type App Engine Admin API
Click on the result App Engine Admin API
Note if "ENABLE" button is shown, if yes, means it was not yet enable, click it to enable the API. If "MANAGE" is shown, means already enabled
Open cloud shell
In the cloud shell:
gcloud auth list
gcloud config list project
git clone https://github.com/GoogleCloudPlatform/php-docs-samples.git
cd php-docs-samples/appengine/standard/helloworld/
gcloud app deploy
gcloud app browse
note the app URL listed in the output of that command, browse accordingly
Example 2: Using Cloud SDK and creating new project
## Assuming GCP cloud SDK was already installed in a Windows machine (at c:\home\bin\gcloud) and gcloud init done to define the account and region
c:\home\bin\gcloud>gcloud config list [accessibility]
screen_reader = False
[compute]
region = asia-southeast1
zone = asia-southeast1-a
[core]
account = xxxxxxxxxxxxxxxx@gmail.com
disable_usage_reporting = True
project = xxxxxxxxx
Your active configuration is: [default]
c:\home\bin\gcloud>gcloud projects create myfaqbase-gae --name=myfaqbase-gae Create in progress for [https://cloudresourcemanager.googleapis.com/v1/projects/myfaqbase-gae].
Waiting for [operations/cp.5923585435789889908] to finish...done.
Enabling service [cloudapis.googleapis.com] on project [myfaqbase-gae]...
Operation "operations/acat.p2-291748116573-8d1feaa5-f357-4644-98bf-915b287e2d2c" finished successfully.
c:\home\bin\gcloud>gcloud config set project myfaqbase-gae Updated property [core/project].
c:\home\bin\gcloud>gcloud config list project [core]
project = myfaqbase-gae
Your active configuration is: [default]
## Check if app engine api (appengine.googleapis.com) and cloud build (cloudbuild.googleapis.com) are enabled
c:\home\bin\gcloud>gcloud services list --enabled NAME TITLE
bigquery.googleapis.com BigQuery API
bigquerystorage.googleapis.com BigQuery Storage API
cloudapis.googleapis.com Google Cloud APIs
clouddebugger.googleapis.com Cloud Debugger API
cloudtrace.googleapis.com Cloud Trace API
datastore.googleapis.com Cloud Datastore API
logging.googleapis.com Cloud Logging API
monitoring.googleapis.com Cloud Monitoring API
servicemanagement.googleapis.com Service Management API
serviceusage.googleapis.com Service Usage API
sql-component.googleapis.com Cloud SQL
storage-api.googleapis.com Google Cloud Storage JSON API
storage-component.googleapis.com Cloud Storage
storage.googleapis.com Cloud Storage API
## To run gcloud app deploy, we also have to enable Cloud Build API, but this new project is not yet billing enabled
## link it to the billing enabled project
# Defaults to "serve index.php" and "serve public/index.php". Can be used to
# serve a custom PHP front controller (e.g. "serve backend/index.php") or to
# run a long-running PHP script as a worker process (e.g. "php worker.php").
#
# entrypoint: serve index.php
c:\home\bin\gcloud\myfaqbase-gae\php-docs-samples\appengine\standard\helloworld>gcloud app create --project=myfaqbase-gae --region=asia-southeast1 You are creating an app for project [myfaqbase-gae].
WARNING: Creating an App Engine application for a project is irreversible and the region
cannot be changed. More information about regions is at
<https://cloud.google.com/appengine/docs/locations>.
Creating App Engine application in project [myfaqbase-gae] and region [asia-southeast1]....done.
Success! The app is now created. Please use `gcloud app deploy` to deploy your first app.
## Deploy the app
c:\home\bin\gcloud\myfaqbase-gae\php-docs-samples\appengine\standard\helloworld>gcloud app deploy
Services to deploy:
Beginning deployment of service [default]...
#============================================================#
#= Uploading 0 files to Google Cloud Storage =#
#============================================================#
File upload done.
Updating service [default]...done.
Setting traffic split for service [default]...done.
Deployed service [default] to [https://myfaqbase-gae.as.r.appspot.com]
You can stream logs from the command line by running:
$ gcloud app logs tail -s default
To view your application in the web browser run:
$ gcloud app browse
## Browse using the default browser
c:\home\bin\gcloud\myfaqbase-gae\php-docs-samples\appengine\standard\helloworld>gcloud app browse
Opening [https://myfaqbase-gae.as.r.appspot.com] in a new tab in your default browser.