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:
- An existing WordPress site on Pantheon, or create a site.
- A local clone of your code repository.
- An account with Google Cloud Platform (GCP). GCP offers free credit) to try out their services.
- Terminus installed on your local computer.
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.
Go to your GCS account, select IAM & Admin, select Service Accounts, and then click Create Service Account.
Name your service account, click Create and Continue, and then click Done to finalize the account creation.
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.
Create a New GCS Bucket
Go to your GCS account, select Cloud Storage, select Buckets, and then click Create Bucket.
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.
Uncheck the Enforce public access prevention on this bucket and select Fine-grained under Access control.
Make sure that Data encryption is set to Google-managed encryption key and then click Create.
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.
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.