As PHP version 5.5 is no longer supported by the community, we strongly recommend new apps use the PHP 7 runtime.

Quickstart for PHP 5 in the App Engine Standard Environment

Region ID

The REGION_ID is a code that Google assigns based on the region you select when you create your app. Including REGION_ID.r in App Engine URLs is optional for existing apps and will soon be required for all new apps.

To ensure a smooth transition, we are slowly updating App Engine to use region IDs. If we haven't updated your Google Cloud project yet, you won't see a region ID for your app. Since the ID is optional for existing apps, you don't need to update URLs or make other changes once the region ID is available for your existing apps.

Learn more about region IDs.

This quickstart shows you how to create a small App Engine application that displays a short message.


There are no costs associated with running this guide. Running this sample app alone does not exceed your free quota.

Before you begin

Before running and deploying this quickstart, install the Cloud SDK and then set up a Cloud project for App Engine:

  1. Download and install Cloud SDK:

    Download the SDK

    Note: If you already have the Cloud SDK installed, update it by running the following command:

    gcloud components update
  2. Create a new project:

    gcloud projects create [YOUR_PROJECT_ID] --set-as-default

    Verify the project was created:

    gcloud projects describe [YOUR_PROJECT_ID]

    You see project details that might look like the following:

    createTime: year-month-hour
    lifecycleState: ACTIVE
    name: project-name
    id: '433637338589'
    type: organization
    projectId: project-name-id
    projectNumber: 499227785679
  3. Initialize your App Engine app with your project and choose its region:

    gcloud app create --project=[YOUR_PROJECT_ID]

    When prompted, select the region where you want your App Engine application located.

  4. Make sure billing is enabled for your project. A billing account needs to be linked to your project in order for the application to be deployed to App Engine.

    Enable billing

  5. Install the following prerequisites:

App Engine locations

App Engine is regional, which means the infrastructure that runs your apps is located in a specific region and is managed by Google to be redundantly available across all the zones within that region.

Meeting your latency, availability, or durability requirements are primary factors for selecting the region where your apps are run. You can generally select the region nearest to your app's users but you should consider the location of the other Google Cloud products and services that are used by your app. Using services across multiple locations can affect your app's latency as well as pricing.

App Engine is available in the following regions:

  • northamerica-northeast1 (Montréal)
  • us-central (Iowa)
  • us-west2 (Los Angeles)
  • us-east1 (South Carolina)
  • us-east4 (Northern Virginia)
  • southamerica-east1 (São Paulo)
  • europe-west (Belgium)
  • europe-west2 (London)
  • europe-west3 (Frankfurt)
  • europe-west6 (Zürich)
  • asia-northeast1 (Tokyo)
  • asia-northeast2 (Osaka)
  • asia-east2 (Hong Kong)
  • asia-south1 (Mumbai)
  • australia-southeast1 (Sydney)

You cannot change an app's region after you set it.

If you already created an App Engine application, you can view the region by doing either of the following:

This quickstart assumes that you are familiar with the PHP programming language.

Download the Hello World app

We've created a simple Hello World app for PHP so you can quickly get a feel for deploying an app to Google Cloud Platform. Follow these steps to download Hello World to your local machine.

  1. Clone the Hello World sample app repository to your local machine in a directory called helloworld:

    git clone -b phase0-helloworld helloworld
  2. Then go to the directory that contains the sample code:

    cd helloworld

Alternatively, you can download the sample as a .zip file and extract it into a directory called helloworld.

Test the application

Test the application using the local development server (, which is included with the SDK.

  1. From within the helloworld directory where the app's app.yaml configuration file is located, start the local development server with the following command: app.yaml

    The local development server is now running and listening for requests on port 8080. Something go wrong?

  2. Visit http://localhost:8080/ in your web browser to view the app.

Running the local development server (

To run the local development server, you can either run by specifying the full directory path or you can add to your PATH environment variable:

  • If you installed the original App Engine SDK, the tool is located at:

  • If you installed the Google Cloud SDK, the tool is located at:


    Tip: To add the Google Cloud SDK tools to your PATH environment variable and enable command-completion in your shell, you can run:


For more information about running the local development server including how to change the port number, see the Local Development Server reference.

Make a change

You can leave the development server running while you develop your application. The development server watches for changes in your project files, and reloads them if necessary.

  1. Try it now: Leave the development server running, then edit helloworld.php to change Hello, World! to something else.
  2. Reload http://localhost:8080/.

Deploy your app

To deploy your app to App Engine, run the following command from within the root directory of your application where the app.yaml file is located:

gcloud app deploy

Learn about the optional flags.

Common gcloud command flags

  • Include the --version flag to specify an ID that uniquely identifies that version of your app, otherwise one is generated for you. Example: --version [YOUR_VERSION_ID]
  • Include the --project flag to specify an alternate Cloud project ID to what you initialized as the default in the gcloud tool. Example: --project [YOUR_PROJECT_ID]


gcloud app deploy --version pre-prod-5 --project my-sample-app

To learn more about deploying your app from the command line, see Deploying a PHP 5 App . For a list of all the command flags, see the gcloud app deploy reference.

View your application

To launch your browser and view the app at, run the following command:

gcloud app browse


You have completed this quickstart.

See the following sections for information about cleaning up after this quickstart as well as links to the possible next steps that you can take with your deployed applications.

To learn more about this Hello World app, see the Hello World code review section.

Clean up

To avoid incurring charges, you can delete your Cloud project to stop billing for all the resources used within that project.

  1. In the Cloud Console, go to the Manage resources page.

    Go to the Manage resources page

  2. In the project list, select the project that you want to delete and then click Delete .
  3. In the dialog, type the project ID and then click Shut down to delete the project.

What's next

Use a custom domain

You can serve your App Engine app using your own custom domain instead of For more information, see Using Custom Domains and SSL.

Hello World code review

Hello World is the simplest possible App Engine app: it contains only one service, has only one version, and all of the code is located within the app's root directory. This section describes each of the app files in detail.


The helloworld.php script responds to any HTTP request with the message Hello, World!.


echo 'Hello, World!';


The app.yaml configuration file describes which handler scripts should be used for which URLs.

runtime: php55
api_version: 1
threadsafe: true

- url: /.*
  script: helloworld.php

From top to bottom, this configuration file says the following about this application:

  • This code runs in the php55 runtime environment, API version 1.
  • This application is threadsafe so the same instance can handle several simultaneous requests. Threadsafe is an advanced feature and can result in erratic behavior if your application is not specifically designed to be threadsafe.
  • Every request to a URL whose path matches the regular expression /.* (all URLs) should be handled by the helloworld.php script.

The syntax of this file is YAML. For a complete list of configuration options, see the app.yaml reference.


The following is a common error message that you might encounter:

ERROR: (gcloud.config.set) argument VALUE: Must be specified.
If you encounter this error when running the gcloud app deploy command, you need to run the gcloud init command to ensure that the tool has been initialized and your Cloud project ID is set.
The development server must be started with the --php_executable_path flag set to the path of the php-cgi binary.

If you encounter this error when running, you need to rerun with the flag php_executable_path and specify the path to your php-cgi binary. On Linux and Mac systems, you can find the path by running the following command:

which php-cgi

Example of the command with the --php_executable_path flag set to the /usr/bin/php-cgi path:

python helloworld/ --php_executable_path /usr/bin/php-cgi

Learn more

Learn the whole platform

Now that you know what it's like to develop and deploy App Engine apps, you can stretch out and see the rest of Google Cloud Platform. For a guided walkthrough that teaches you how to create an application that uses the entire platform, not just App Engine, check out our Creating a Guestbook tutorial in which you expand this simple application to become a fully-fledged Guestbook application that lets authenticated Google accounts post messages to a public page.

Learn more about App Engine standard environment

Here are some topics to help you to continue learning about App Engine.