In this tutorial, you will learn how to host a free website on Google Cloud Platform. This is possible on the Google Cloud Platform free tier.

By the end of this tutorial, you will have a fully-functioning WordPress website running on an Nginx web server. Let’s get started.

Get $300 Free Google Cloud Credits

== 1. Create a Google Cloud Platform Account ==

First things first. Create yourself a Google Cloud Platform (GCP) account. This video will walk you through the process of setting up your GCP account if you don’t already have one. YouTube video

== 2. Spin Up a Compute Engine VM on the Free Tier ==

From the GCP dashboard, click on Compute Engine. Create a VM instance.

In order to create your VM instance on the free tier, you must configure your VM with the following restrictions:

- Non-preemptible f1-micro VM instance

- US regions: Oregon (us-west1), Iowa (us-central1), or South Carolina (us-east1)

- Up to 30 GB-months HDD

Notice how it says “Your first 744 hours of f1-micro instance usage are free this month”. This number will vary depending on how many days are in the current month. For example, this screenshot was from October which has 31 days.

31 days x 24 hours = 744 hours

Feel free to choose any operating systems for the boot disk. In this tutorial, I chose Ubuntu 20.04 LTS.

Get $300 Free Google Cloud Credits

== 3. Connect your Domain Name (optional) ==

You can optionally associate a domain name with your IP address. If you don’t have a domain name, feel free to skip ahead to the next step.

Otherwise, you can use create a DNS A record at your domain registrar with a value of the IP address of your Google Cloud Platform VM instance.

In Google Domains, for example, you can add the DNS A records for your domain name. The screenshot assumes the IP address of your VM instance is

It can take up to 48 hours for your domain name to become associated with your IP address, but it usually happens within a few minutes.

== 4. Login to Your Server ==

You have a few different options for logging in to your VM instance. The easiest way is to select the “Open in browser window” which will log you in to your VM instance without the need to provide any credentials.

You can also use the gcloud command to log in via the command line or terminal.

== 5. Update Your VM ==

Once you’re logged in to your server, the first thing you want to do is update your system.

sudo apt update sudo apt upgrade

== 6. Install the Web Server, Database, and PHP ==

Use the apt package manager to install the Nginx web server, Mariadb database, and PHP.

sudo apt-get install nginx mariadb-server php-fpm php-mysql

== 7. Setup the WordPress Database ==

First, secure your database installation. After executing the following command, answer

Y for each security configuration option.

sudo mysql_secure_installation

Create a database and user with appropriate privileges for WordPress. Access the MySQL command prompt by simply typing


create database example_db default character set utf8 collate utf8_unicode_ci; create user 'example_usernamelocalhost' identified by 'example_password'; grant all privileges on example_db.* TO 'example_usernamelocalhost'; flush privileges; exit

== 8. Install WordPress ==

Next let’s download and install the latest version of WordPress from the official website.

cd /var/www sudo wget sudo tar -zxvf latest.tar.gz sudo rm latest.tar.gz

Also, change the owner and group of the WordPress root directory to www-data.

sudo chown www-data:www-data -R wordpress/

== 9. Configure Nginx to Serve Your WordPress Website ==

Make a configuration file for your WordPress website at

/etc/nginx/sites-available/example.conf with the following content adjusted accordingly for your website. Of course, feel free to name your configuration as you see fit.

upstream example-php-handler { server unix:/var/run/php/php7.4-fpm.sock; } server { listen 80; server_name; root /var/www/wordpress; index index.php; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass example-php-handler; } }

You will need to change the server_name option to your domain name, or if you don’t have a domain name, simply change this line to


Also, depending on what version of PHP was installed, you may need to update line 2 to the actual version of PHP that’s installed on your server.

Finally, publish your website by making a symlink from your

sites-available/example.conf file to the

sites-enabled directory.

sudo ln -s /etc/nginx/sites-available/example.conf /etc/nginx/sites-enabled/

You will also want to remove the default Nginx config file like this.

sudo rm /etc/nginx/sites-enabled/default

Test your Nginx configuration changes and restart the web server.

nginx -t systemctl restart nginx

== 10. Setup WordPress ==

Navigate to your IP address or domain name (in this case and you’ll see the famous five-minute WordPress installation process. In reality, it take about a minute to fill out this form.

Give your website a title, username, and secure password.

After clicking on the Install WordPress button, you’ll have a brand-spanking new copy of WordPress on your web server. Feel free to pick out a theme (I recommend GeneratePress), write some blog posts, and make your website fast with caching plugins.

If you want to make another WordPress website, you can follow this tutorial that will teach you how to host multiple WordPress websites on a single server. This won’t incur any additional charges on Google Cloud Platform, but please be aware that you are limited to 1 GB of network egress per month. If you don’t know what this means, I explain it all in this video.

Other next steps include installing an SSL certificate on your server to enable HTTPS and make your website secure.

Any questions, let me know in the comments below.

Get $300 Free Google Cloud Credits