Deploying to Google App Engine

To deploy to Google App Engine, use the app command group. The App Engine allows us to host websites developed in PHP, Java, Go, or Python in the standard environment. To deploy a sample app to the App Engine instance that was created in Chapter 1, Google Cloud and Google BigQuery, follow the steps listed here:

  1. Download the sample PHP file and app.yaml file from the GitHub URL (https://github.com/hthirukkumaran/Learning-Google-BigQuery/tree/master/chapter2/phpapp) to a folder on the local computer. This PHP code connects to the Cloud SQL instance of the same project, executes a sample query, and displays the result.
  2. Open the index.php file and modify the $dsn variable value to point to your Cloud SQL instance. To get the full qualified Cloud SQL instance name, open the Cloud SQL instance in your project. Copy the value of the instance connection name and paste that value instead of the following value into the PHP file. Change the dbname in the $dsn variable to your database name. Change the values of $username to the database username in Cloud SQL you want to use, and $password to the password of the user specified in the $username variable:
my-first-project-170319:us-central1:trainingdbserver
  1. Save the changes, open the Terminal, and go to the directory where the app.yaml and index.php are located. Type the following command to deploy your changes to the App Engine instance you created in the previous chapter. If asked for confirmation to deploy press Y:
gcloud app deploy
  1. Once the app is deployed, type the following command to open the app in the browser and view the screen. If you encounter any errors, you can see the error in the Error Reporting option of the menu:
gcloud app browse
  1. If you encounter any permission errors while the app is connecting to the Cloud SQL instance, check to make sure that permission is granted for the App Engine to connect to Cloud SQL under the section App Engine authorization, as shown in the following screenshot:
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.209.131