Migrating Wordpress to App Engine - Configuring GCP

  • Written by John
  • May 2nd, 2019

Now you’ve setup your Windows or Linux environment we need to configure a Google Cloud Platform project. Once configured you can deploy Wordpress into App Engine. If it is your first project, you can get $300 of free credit for one year, providing you don’t burn through it.

Before we start to configure GCP, a few things to note.

  1. I will be creating a project called goggs-wordpressgae
  2. goggs-wordpressgae is a burn project and will be deleted after this series
  3. GCP requires a debit or credit card

With that out of the way, let’s get started.

App Engine

App Engine is a PaaS (Platform as a Service) that allows you to run applications without requiring you to spend time managing your infrastructure, giving you more time to spend on developing your applications.

To setup a new project, head on over to https://console.cloud.google.com.

GCPGettingStarted

Click on select a project at the top and click on new project.

01SelectProject 02NewProject

Enter a project name^[Your project name must be globally unique.], set the location^[If your Google account is licensed, change the location to the name of your GSuite organisation. If you’re having difficulties, please see your GSuite or GCP administrator.] and click on create.

03CreateProject

Cloud Console will take 20-30 seconds to build your project. You can check the status of your project by viewing the notifications tray in the top right corner. Once your project has created, navigate to App Engine.

AppEngineNavigation

When you visit App Engine for the first time, you’ll find a couple of items that’ll show you how to run your first app. Click on create application to enable and configure App Engine.

AppEngineLandingNotConfigured

Select which region you want your application to run in and click on create app. Bear in mind App Engine may not be available in all regions and can’t be altered once set. Click here to see a list of App Engine locations.

AppEngineRegionSelect

Once you’ve selected your region, you can choose which language your application will run in. This step is optional but will allow GCP to link you to resources that will help you to run and deploy your application.

AppEngineSetupCompleted

We’ve already setup the GCloud SDK so we can skip this step. The App Engine dashboard will now show you App Engine has been initialised and you can start to run your applications.

AppEngineDashboardConfigured

Before you deploy Wordpress to App Engine, we need to setup a Cloud SQL environment.

Cloud SQL

Cloud SQL is Google’s SQL platform. It allows you to run SQL databases within the cloud for your applications. You can create MySQL or Postgres SQL databases.

Navigate to the SQL service and click on create instance. Select MySQL as your database engine.

SQLCreateInstance SQLServerType

Next, you can configure the size of your instance, automated backups, MySQL version and more. Below is the configuration I have used.

Once you’re finished with the configuration of your SQL instance, click create.

When your instance has created, we want to enable SSL connectivity to the instance, ensuring connections to the instance are secure. Go into your instance, click on connections and click on allow only SSL connections.

SQLAllowSSLConnections

Best Practices for Configuration

Cloud Storage

Cloud Storage is Google’s storage platform. Here, you can setup storage buckets to store your files. You’ll need to setup a storage bucket to store images for your Wordpress site.

Navigate to Storage within GCP to create a bucket. As you have enabled App Engine, there are two buckets that App Engine created. When deploying your application to App Engine, the deployment process will use these buckets.

StorageDefaultBuckets

We need to create a new bucket to allow your Wordpress site to store images. This bucket will be publically available, so we need to set the correct permissions. To do this, click create bucket at the top, give it a name and select the storage class you require.

StorageBucketConfig

I’ve configured this bucket for object level access instead of bucket level access to allow me to control permissions on a granular level.

We need to enable objects (files and folders) within the bucket to be publically available. When you’re inside the bucket, click on the permissions tab, then click on add members. In the new members box type in allUsers and, assign the roles Storage Object Viewer and Storage Legacy Object Reader.

StoragePermissions StoragePublicPermissions

The additional permission will now show in the list of permissions assigned to the bucket. You will receive a warning advising the bucket is public and can be accessed by anyone.

StorageAddedPublicPermissions