How To Host a WordPress Website on Google Cloud Platform by IdeaSpot.

Mojo April 17, 2024

How To Host a WordPress Website on Google Cloud Platform by IdeaSpot.

Hosting a WordPress Website on Google Cloud Platform for Free

Are you looking to host your WordPress website on Google Cloud Platform (GCP) without spending a dime? You’re in the right place! In this comprehensive guide, we’ll learn the steps to host your WordPress site on GCP for free. You can benefit from reliable hosting, scalability, and performance by leveraging Google’s cloud infrastructure without breaking the bank.

Video Credit to

Step 1: Setting Up a Google Cloud Platform Account

The first step is to create a Google Cloud Platform account if you don’t already have one. Google often offers new users free credits, which you can use to host your website without incurring costs initially. Once you set up your account, navigate to the Google Cloud Console, where you’ll manage your resources.

Step 2: Creating a Virtual Machine Instance

In the Cloud Console, go to the Compute Engine section and click on “VM instances.” You’ll create a new virtual machine (VM) instance to host your WordPress site here. Click the “Create” button and configure your VM settings, including:

  • Machine Type: Choose an appropriate machine type based on your website’s expected traffic and resource requirements. For a small-scale site, a standard machine type should suffice.
  • Boot Disk: Select a Debian or Ubuntu image for your VM’s boot disk. These operating systems are well-suited for hosting WordPress.
  • Firewall: To enable web access to your site, ensure that HTTP (port 80) and HTTPS (port 443) traffic are allowed in the firewall settings.

Once configuring these settings, click “Create” to provision your VM instance.

Step 3: Installing WordPress

With your VM instance ready, it’s time to install WordPress. Connect to your VM using SSH from the Cloud Console or any SSH client you choose. Once connected, follow these steps:

  1. Update the package list: sudo apt update
  2. Install Apache web server, MySQL, PHP, and other necessary packages:
   sudo apt install apache2 mysql-server php php-mysql libapache2-mod-php php-cli php-curl php-gd php-mbstring php-xml php-xmlrpc
  1. Secure your MySQL installation by running: sudo mysql_secure_installation
  2. Create a MySQL database and user for WordPress:
   sudo mysql -u root -p
   CREATE DATABASE wordpress;
   CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'your_password';
   GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
  1. Download and extract WordPress:
   tar -xzvf latest.tar.gz
   sudo mv wordpress /var/www/html/
  1. Set appropriate permissions:
   sudo chown -R www-data:www-data /var/www/html/wordpress
   sudo chmod -R 755 /var/www/html/wordpress

Step 4: Configuring WordPress

Next, configure WordPress to connect to your MySQL database and set up your site:

  1. Rename the WordPress configuration file: sudo mv /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php
  2. Edit the wp-config.php File and update the database details:
   sudo nano /var/www/html/wordpress/wp-config.php

Update the following lines with your database name, user, and password:

   define('DB_NAME', 'wordpress');
   define('DB_USER', 'wpuser');
   define('DB_PASSWORD', 'your_password');
  1. Save and close the file.

Step 5: Setting Up Domain and SSL

To access your WordPress site with a custom domain and SSL certificate, follow these steps:

  1. Obtain a domain name and point it to your VM’s external IP address using DNS settings.
  2. Install Certbot to generate SSL certificates:
   sudo apt install certbot python3-certbot-apache
  1. Obtain SSL certificates for your domain:
   sudo certbot --apache -d

Follow the prompts to configure SSL.

Step 6: Accessing Your WordPress Site

Once everything is set up, you can access your WordPress site by navigating to your domain name in a web browser. Complete the WordPress installation by providing the required details (site title, admin username/password, etc.).

Step 7: Monitoring and Maintenance

Regularly monitor your website’s performance and security. Use tools like Google Cloud Monitoring and Google Cloud Security Command Center to detect and address any issues promptly.


With the right setup and configuration, hosting a WordPress website on Google Cloud Platform for free is achievable. By leveraging GCP’s infrastructure and services, you can ensure reliable performance and scalability for your site without incurring significant costs. Follow the steps outlined in this guide, and enjoy hosting your WordPress site on the Google Cloud Platform hassle-free!