Skip to main content
Last Reviewed: June 01, 2023

Google Cloud Storage Setup for WordPress

Add GCS storage integration to a WordPress site on Pantheon.


This section provides information on how to integrate Google Cloud Storage (GCS) with your WordPress Pantheon site.

GCS is a scalable storage and content distribution solution that you can integrate with sites running on Pantheon. Pantheon already offers content distribution through our Global CDN, but GCS is a good option to address issues with highly populated directories or serving large files and as alternative for AWS S3.

Before You Begin

Be sure that you have:

Code:
Exports

This process uses Terminus commands. Set the variable $site in your terminal session to match your site name before you begin:

export site=yoursitename
export env=dev

Configure Google Cloud Storage within the AWS Console

You must configure the service within your Google Cloud Console before integrating Google Cloud Storage with your Pantheon site.

Create a Google Service Account

You must have a service account to programmatically access your GCS bucket and assign fine-grain access.

  1. Go to your GCS account, select IAM & Admin, select Service Accounts, and then click Create Service Account.

    GCS Service account 1

  2. Name your service account, click Create and Continue, and then click Done to finalize the account creation.

    GCS Service account 2

  3. Note the email that is automatically assigned to your service account, select the Keys tab, select JSON in the pop-up, then click Create. This downloads a JSON file. Make sure you store this JSON file securely.

    GCS Service account 3

Create a New GCS Bucket

  1. Go to your GCS account, select Cloud Storage, select Buckets, and then click Create Bucket.

    GCS Bucket Settings 1

  2. Name your bucket, select Region, and then select the region from the drop-down menu that is closest to your website (US, Canada, Europe or Australia) during site creation.

    GCS Bucket Settings 2

    GCS Bucket Settings 3

  3. Uncheck the Enforce public access prevention on this bucket and select Fine-grained under Access control.

    GCS Bucket Settings 4

  4. Make sure that Data encryption is set to Google-managed encryption key and then click Create.

    GCS Bucket Settings 5

  5. Go to the Permissions tab, click the Grant Access button, enter the email that was automatically assigned under your service account in the New Principal field, select Storage Admin under Assign Roles, and then click Save.

    GCS Bucket Settings 7

Integrate Google Cloud Storage (GCS) in WordPress

You must install a plugin such as WP Offload Media Lite or WP Stateless to integrate GCS with WordPress.

WP Offload Media Lite is a free version but there is a premium version that includes support and additional features, such as multisite support. Refer to installation and configuration for instructions.

WP-Stateless is another option for GCS integration. Refer to the full installation guide for instructions.

URL Rewriting

URLs saved in the database use GCS-provided URLs (for example, https://storage.googleapis.com/example.com/2023/1/image.jpg) by default.Advanced Global CDN can mask the URLs to match your site's domain for SEO purposes. Contact sales if you do not have AGCDN or open a support ticket to request Domain Masking if you have AGCDN.

More Resources