Deploying WordPress on Google Cloud

Full Stack WordPress Development on GCP

Joe Alongi
9 min readApr 5, 2020

WordPress has been a main-stead on the internet for years, having established a strong presence for developing RSS & XML feeds making WordPress one of the most successfully indexed blog platforms.

Delivering WordPress to the internet has been a balanced science over the last decade. Thousands of solutions, hundreds of themes, and many choices in hosting have delivered catered experiences to its presence.

Testing & developing many methods of functionality extend beyond that of the site. Focusing options in hosting & optimization brings a new layer of success to WordPress solutions and Progressive Web Applications as mentioned previously in “The Superhero Stack”.

Researching the most prominent solutions in hosting for WordPress, with insight from Google, the top tier solutions begin to become presently focused. When reaching towards developing a PWA (Progressive Web Application), it is important to understand the considerations in Kinsta, WordPress Engine & Google Cloud Platform.

Google Cloud Platform for Global Services & Auto-Scaling

Building a stack to support WordPress creates an awareness of the technologies that develop the solution. WordPress configurations can seem overwhelming to those transferring in from a maintained installation as the recommended or options like GoDaddy, BlueHost, and DreamHost.

Developing on Google Cloud Platform has many available benefits with streamlined integrations packed by Google Cloud services. Extending the value of WordPress as a solution, when abstracting the architecture behind its stack.

From Cloud DNS management, Load Balancing and Instance Scaling to API integration even expanded to Anthos clusters — GCP (Google Cloud Platform) is ready to support any scale of WordPress builds with SaaS tier technologies.

WordPress Open Source Software for Websites, Blogging, and Publishing

There are many existing variances of WordPress to speed up caching, those built to specific web server integrations, and those established in expanded databases. Along with the differentiation of WordPress configurations, are tiers of cloud computing that are established to support an installation. From virtual compute engine instances to Kubernetes through Anthos clusters, WordPress will run on any tier of GCP (Google Cloud Platform).

As an example of running WordPress on the cloud through Google, the focus of developing from a starting perspective would utilize the preconfigured WordPress install through Google Marketplace, on a virtual machine in a compute engine, utilizing PHP, SQL, Apache & WordPress-CLI via Debian OS. Choosing these options is a quick click-through to sign up and install from the onboarding page WordPress Hosting Options.

Step 1: Installing WordPress

Following the single instance installation for Deploying WordPress using GCP (Google Cloud Platform), the process is quite simple and will focus on options for choosing the VM (Virtual Machine) settings that support the WordPress install.

Step 2: Deploying WordPress

Click the “Launch” button to begin the process, a GCP (Google Cloud Platform) account is required through Google, after login, create a project to install the WordPress instance.

Step 3: Virtual Machine

Google recommends, WordPress runs best in a Compute Engine n1-standard-1 instance (1 CPU) at $24.27/mo.

Configuring a smaller environment can be great for testing & development, saving costs on VM’s (Virtual Machines) that can be scaled later to fit the solution & server usage. The base configuration, lowest scale, is n1-shared-0.6 (1 shared vCPU) at $5.13/mo. Short of best practices, it will get the platform started for cloud hosting of WordPress via GCP (Google Cloud Platform).

Developing WordPress on a Remote Cloud Virtual Machine Instance

Development can now proceed through SSH, FTP, or directly through the admin panel provided by the WordPress install. Building the site outfits many paths in modern WordPress development and can be simple as copy and pasting the admin login with a temporary password.

The familiar presence of WordPress becomes engaged here, much contrasted with any hosting platform, the difference between most hosting solutions, is the self-installation of management platforms such as CPanel, FTP and additional services like Cloudflare.

If familiar with phpMyAdmin, SSH, and WordPress Dashboard, there is little additional configuration to get the development flow up and running. Version control management spans across developers and engineers, integrations are supported in different ways, though there are several sources of documentation for integration on Google’s Support Documentation and the internet.

Step 4: Static IP Addresses

A Static IP will align all content, information, and development on that server with a specific entity, in reference the internet will resolve more relevance to Static servers, this is a core step in connecting your custom domain as well.

From the hamburger menu on the top left, scroll down to Networking>VPC Network>External IP addresses. Choose the server IP for the WordPress VM (Virtual Machine) and promote the Ephemeral IP to a Static IP.

Step 5: Custom Domains

A custom domain will allow you to point a URL (Uniform Resource Locator) to a server IP address. This logic is familiar to a hosting provider managing the name servers of a domain, though here, it is all managed through the GCP (Google Cloud Platform).

Proceed to Google Domains to purchase a domain for the WordPress project. This platform will provide a simple way to manage DNS, G Suite, and forwarding resources with a click of a button.

Step 6: Cloud DNS

Cloud DNS (Domain Name System) creates zones for mapping the Domain, hosting the Nameservers and provides a service for connecting the custom domain to the server IP.

From the hamburger menu on the top left, scroll down to Networking>Network Services>Cloud DNS. Choose “Create Zone”, and begin to follow the procedure below. Important Note: the update of this process may take 48/HRS

Begin this process by naming the zone container in the Zone name field as the project name, then enter the URL in the field DNS name to initiate a container for the following entries.

A. In the zone editor click “Add Record Set”. Create an (A) record and in the field IPv4 Address, enter the Static Server IP generated in Step: 4, and click “Create” to save the record to the zone.

B. Once again In the zone editor click “Add Record Set”. Create a (CNAME) record and in the field DNS Name, enter www, then in the field, Canonical Name enter [customdomain.com.] and click “Create” to save the record to the zone.

C. To forward a domain to the server, the Nameservers generated by GCP (Google Cloud Platform) need to replace those in the domain host. Transfer the Nameservers generated, into the custom Nameserver fields, in Google Domains, click (+) to add the additional fields.

Step 6: WordPress URL

Activating the URL within WordPress will allow for the URL to direct over the Server IP. Through this process, the site & dashboard will be accessible via the IP until these changes are set.

From the hamburger menu on the top left, scroll down to Tools>Deployment Manager>Deployments. Choose “Access the phpMyAdmin web interface” under Suggested Next Steps.

A. In phpMyAdmin navigate the structure in the left menu WordPress>wp_options. Once chosen this selection presents a list of options.

B. Two (2) options require updating, the “siteurl” and “home”, this is where to input, via edit, updating the field “option_value” with http://[customdomain.com].

Step 7: SSL (Secure Sockets Layer)

SSL (Secure Sockets Layer) provides an encrypted and secure connection to the website, then to the client and back. This is ideal for purchases, downloads, and user connections to the server from the web client.

From the deployment menu within GCP (Google Cloud Platform)>Access the SSH (Secure Shell)>Apache, configuration begins here.

A. EFF (Electronic Frontier Foundation) provides the SSL registration, certificate, and CERBOT that writes the certification to the server. The ease of installation is to support the internet with a secure layer, CERTBOT and the next step follows along with the Electronic Frontier Foundation Certbot.

B. Once finished selecting the proper HTTP server and OS, in this instance Apache on Debian 9, EFF provides instructions to install the bot, add the certification.

C. As a final step to ensure the installation and process run this Apache command:

sudo service apache2 restart

An effective restart will properly install the certificate and refresh the server, which will enable the SSL protocol to function through the server, make sure to include all domains & subdomains intended to use.

D. SSL will enable the HTTPS access to the web browser, to make full use, revisit Step 6 to update the two (2) fields again with the new https://[customdomain.com].

Step 8: Permalinks

Permalinks allow for the adjustment of trailing posts titles, most frequently, the name of the post is used for SEO (Search Engine Optimization) and proper page allocation.

Login to the WordPress Admin Dashboard https://www.[customdomain].com/wp-admin>Login>Settings>Permalinks set to Post name.

A. Once the permalinks are activated the configuration with the WordPress .htaccess will be set with the proper rewrite function to enable the page name structure. The additional step is to enable the server to run the same rewrite function to avoid web errors.

B. Test the functionality of the WordPress .htaccess by installing the WordPress File Manager. Once installed navigate to the file from the root folder named html, then scroll to .htaccess and right-click to edit, making sure the file reads as below.

# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

If the above information is correct the permalinks are are functioning as they should, if it suits the install, copy the above and place it into the file.

C. Open the SSH once again through the deployment manager and run the below command to open the Apache 2 config.

sudo nano /etc/apache2/apache2.conf

D. Once the configuration is open, scroll down to the <Directory /var/www/> using the arrow keys, remove the # that comments out this entire section. In this section adjust the AllowOveride setting, to reflect as below.

<Directory /var/www/>        
Options Indexes FollowSymLinks
AllowOverride FileInfo
Require all granted
</Directory>

Once the file is updated, the setting will be ready to save within the config, press CTRL+O to save, then CTRL+X to exit. Apache is now configured to enable rewrites for pages, follow Step 7 — Part C to restart the server.

Google Cloud for Maintaining Performant Software Development

Congratulations, WordPress is now running on GCP (Google Cloud Platform) VM (Virtual Machine) with a configured web server that is scalable to support downloads, blogs, users, traffic, plugins, and even application integrations.

The benefits of having a cloud-based solution that is hosted without limitation to scale is similar to the development practices of modern SaaS solutions. Modern applications run on serverless architectures because of the fluidity of scale, the accessibility of custom server configuration, and the ability to interlock top-tier technology.

The future is bright for the expansiveness of utilizing WordPress as a core element of a product & community with extensible surrounding features to rapidly develop extended implementations.

Additional Resources & Development:

Join in on the adventure at heyitsjoealongi.com and on X, Instagram, GitHub, and LinkedIn. For more articles like this subscribe on Substack.

--

--

Responses (1)