Running a WordPress blog on a VPS (Virtual Private Server) can be expensive, especially when you have just begun writing or in case it’s just a personal travel blog which gets a few hundred visitors per week. The minimum for which you can get a dedicated server hosting is for at least 5$ a month, which might not be a lot for you, but might be worth a lot to someone else. If you love the command line you’ll probably like to get your hands dirty and start setting up stuff on your own server rather than getting those free WordPress hosting plans. 

In the following article I’m going to help you run a WordPress blog on Google Compute Cloud – For Free.

Hosting a WordPress Site

WordPress plans including a custom domain name.

There are multiple ways of hosting a WordPress blog. 

  1. Hosting on, which only provides a free subdomain.
  2. Self hosted WordPress on a VPS.
  3. Hosting WordPress on Shared/dedicated hosting.

In this article, we’re going to explore the second option in detail on how you can self host a WordPress blog on your own server without any reoccurring monthly costs. And as an added bonus, you can use the free server for other similar projects.

Pros of self hosted WordPress:

  • Hassle free management, you can just login to the server and execute the necessary commands.
  • No charges for adding your own domain ( charges at least 5$/Month)
  • Manual web server performance tweaks 
  • No struggling with cPanel (understandable if you’re not a UI person).

So let’s dive into it, how it all works. Google has recently launched a “Always free tier” of its cloud services. The free resources are not much, but they should more than suffice any personal needs of a user. Under the Always Free Tier you can run a Google Compute Engine instance with minimal resources free for a month, every month. We’re going to use this free VPS provided by Google to run our WordPress site using the nginx high performance web server.

Google Free Tier

Google being the amazing company it is, has made basic computing free for all. All an individual needs is the will to reap the free benefits provided by the internet giant. 
Up till last year Google just provided a $300 trial credit across all their cloud services for a year. But recently along with the free trial Google has introduced Always free services which include Google app engine, Highly scalable NoSQL databases, high performance virtual machines, Cloud storage and so much more. Please visit for checking out all the free tier services provided by Google under this initiative. Here we’re going to use the free virtual machine (or VPS terms used interchangeably), and the rest of services are a story for another time. 

The free VPS Google provides, the f1-micro machine is in no way performance intensive (don’t get me wrong, I really appreciate it), but it can handle a WordPress blog as long as the traffic is not much. These machines can be used to host experimental projects on which you don’t want to spend any money on, or they can be used to run multiple scripts that you might want to run periodically on a reliable cloud machine.

Setting up the WordPress blog

There are primarily 3 steps in getting the WordPress blog up and running.

  1. Signup on Google Cloud and create the machine.
  2. Integrate Cloudflare for your domain (Optional but recommended).
  3. Install nginx and setup WordPress on the Compute engine instance.

Step 1. Google always free account

  • Sign up on Google cloud and login to cloud console
  • Create your first project (a project is just a name under which you group various Google cloud services, for example your Compute Engine machines)
  • Once you’ve created a project, you need to enable billing for that project before you can create any machines. This step requires you to have an international debit/credit card. (If you don’t have one, generate a virtual card online on Entropay or UsUnlocked)
  • From the left sidebar on cloud console go to Compute Engine -> VM Instances and continue to create a new VM instance.
  • For an eligible free instance, select the following configuration, f1-micro (1 vCPU, 0.6 GB memory), 30 GB HDD.
  • Select a linux distribution on which you’re most comfortable on, Ubuntu 18.04 LTS Minimal is recommended for beginners.
  • Allow HTTP and HTTPS under the firewall section, and paste the ssh public key for logging into your machine.
  • After successful creation of the machine, ssh on the Public Ip using the ssh-key you added in the previous step.
Creation of Free Google Compute Instance

Step 2. Setting up Cloudflare layer

This step is optional but recommended for multiple reasons. Cloudflare acts as a shield between the internet and your site, it can prevent the incoming DDOS attacks, serve traffic as Global CDN, and the best part? It’s all for free too. I’ll be writing a detailed post on the amazing features that Cloudflare provides for free, so keep an eye for that. 

In the following steps we’re telling our Domain name registrar to use Cloudflare DNS servers instead of the default DNS name servers. This helps us intercept and improve the response times for the traffic using Cloudflare.

  • Create an account on Cloudflare.
  • From the Cloudflare dashboard add a new site, and Cloudflare will guide you through the initial setup.
  • Once you’ve updated the name servers on the Domain Name registrar (GoDaddy or similar), we’ll proceed to map our domain to the public IP of the Google cloud instance we just created.
  • For the mapping, we need to edit the DNS records on Cloudflare under our site settings. Screenshot
  • Under the DNS records section of your site on Cloudflare, delete all the existing A records and CNAME records and create a new entry of type A Record with the name as “” and the value as the public ip of your Google instance.
  • Create a new CNAME entry where name=“www” and value=“”.
  • Once all this is done, give it a few minutes since updating DNS records can take sometime (people say upto 24 hours, but usually 5 mins or so).
Cloudflare Control Panel

Step 3. Setting up WordPress with Nginx and mysql

This part is simple, just understand what you’re doing and just copy paste the step wise commands. Since we chose the minimal version of ubuntu, it does not come preinstalled with almost anything. We have to manually install the things we want it to have.

  • Remove the existing apache2 server (nginx is better at performance and handling a lot of traffic)
sudo apt-get purge apache2
  • Install nginx, mysql, php7.2 and required extensions.
sudo apt update 

sudo apt install nginx mysql-server php7.2 php7.2-fpm php7.2-curl php7.2-gd php7.2-intl php7.2-mbstring php7.2-soap php7.2-xml php7.2-xmlrpc php7.2-zip php7.2-mysql nano
  • Set a root password for mysql.
sudo mysql_secure_installation
  • Login to mysql using the password you just created and create the database for your site.
#Login using the command

mysql -u root -p

#Execute the following commands in mysql shell


GRANT ALL ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'password';


  • Downloading the latest version of WordPress, creating the home directory for site.
cd /var/www/ 

sudo curl -LO

sudo tar -xzvf latest.tar.gz

sudo mv wordpress/
  • Configuring WordPress and fixing permissions for the WordPress directory.
cd /var/www/
sudo cp wp-sample-config.php wp-config.php 

curl -s  

# Copy the output of the above command and paste (replace the sample values) in wp-config.php 
# Also update the database name, username and password created previously mysql setup step in the wp-config.php file.

sudo nano wp-config.php  

sudo chown -R www-data:www-data .
  • Configuring nginx and enabling your website in nginx. You can also run multiple websites on a single server using this way.
cd /etc/nginx/sites-available

# remove all the “default_server” directives from the default file

sudo nano default

# Change the following values in the file
listen 80 default_server; -> change to -> listen 80;
listen [::]:80 default_server; -> change to -> listen [::]:80;

  • Create a site configuration file for nginx.
cd /etc/nginx/sites-available 

sudo nano
  • Copy the following server configuration and replace the site directory path and site domain name.
server {
listen 80;
listen [::]:80;
root /var/www/;
index index.php index.html index.htm index.nginx-debian.html;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri /index.php?$args;
location /wp-admin/ {
index index.php;
try_files $uri $uri/ /index.php$args;
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
include fastcgi_params;
location ~* .(jpg|jpeg|png|webp|gif|ico|css|js)$ {
expires 365d;
  • Enable the site configuration in nginx for your domain.
cd /etc/nginx/sites-enabled 

sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/
  • That’s it, restart the nginx web server and php-fpm
sudo service php7.2-fpm restart 

sudo service nginx restart
  • Go to the URL of your site and you should be able to continue the WordPress installation from the browser now.
Welcome Home!

If you have any issues or doubts in any of the steps above, feel free to drop a comment! And stay tuned for more linux stuff!


25 Replies to “Running a Forever Free WordPress Blog with Your Own Domain on Google Cloud

    1. I would not go that far. Forever free tier is good enough for personal blogs and wordpress sites that get around 10,000 visitors a day (maximum).
      For e-commerce, you can get free 300$ credits from Google for a year, that should help you in getting your business off the ground.

      1. it’s true 10K uv/day , how can you determine that number? using server tester like loadimpact or real wordpress site?

        oh by the way, how to cut off the cpu usage, and is it enough to use basic lemp setup to handle 5K uv/day ? i am planing to use nginx cache + redis & keycdn.

    1. Really easy if you have some experience with Linux. But if you don’t then you’ll struggle a bit in the initial phase but if your Google skills are good, you can easily do it.

  1. Thank you very much! I’m no expert by any means. But I think I’ve found some typos/improvements:
    1. sudo mysql-secure-installation
    should be sudo mysql_secure_installation (ie: _ instead of -)
    2. sudo chown -R www-data:wwww-data .
    should be sudo chown -R www-data:www-data . (ie: one too many w)

    1. Are you sure you chose the right region? European accounts default to european servers by default (I think), but the free f1-micro instance only actually is free when hosted in america.

  2. Hi dear!
    I’m beginner in computer science, I would like to create a small travel blog, the first thing I did I bought A domaine name, but I don’t know what to do After? Thanks

  3. I don’t have a debit/credit card what should I do? Although, I tried using my parents card but the billing was suspended please if you have any solution guide me through it.!
    In your blog you have mentioned about virtual card but is it acceptable ?

  4. Good stuff here.
    A few comments.
    1. Google cloud options have changed, need to be updated. For example, F1 Micro is hidden under 1st Generation hardware.
    2. Add a note to change password on this line:GRANT ALL ON wordpress.* TO ‘wordpressuser’@’localhost’ IDENTIFIED BY ‘password’;
    3. Change this line sudo cp wp-sample-config.php wp-config.php to be sudo cp wp-config-sample.php wp-config.php

  5. Thank you for the great article!
    I run a website for a 501(c)(8) non-profit organization. We have very low traffic. But we do have online credit card transactions.
    What about this type of setup makes it not appropriate for such a website? Of course, security is top priority. How secure is this setup?
    I have some linux knowledge. I am learning, but I’m certainly not an expert yet. I am also doing self-study on computer security.
    Of course, a self-managed site will be vulnerable if not set up properly or kept up-to-date. But overall looking at this setup, what comments do you all have about security?

  6. This worked great for me! I picked a Debian 10 instance, and had to be careful to get one in the us-east-1 zone, and the N1 CPU type to get access to the F1 free instance. Debian only has mariadb-server – which is a drop-in replacement for the non-free MySQL. Also packages had now changed to php7.3-xxxx – so my apt-get statement changed a bit. Everything else was fine.

  7. Thank you so much for this info. My ecommerce site is hosted on Shopify, and when looking to add a simple Quiz based sizing system, Shopify apps would have charged >30 USD a month just for that simple functionality. A paid WordPress Quiz plugin is a one time charge + whatever hosting costs. I looked into free WordPress hosting, but I was uncomfortable with sending my customers to a potentially unsafe hosting environment. I then looked for VPS plans, and many seemed perfectly adequate, but with Google’s always free cloud computing tier, the hosting cost is pretty much moot. I have to admit that after a few frustrating attempts to get the instructions to work, I had to modify them, opting to use a Bitnami WordPress instance, with the same f1-micro VM specs, albeit with Debian as opposed to Ubuntu as Sarah, above, opted for. Theoretically, the requirements for an always free GCP instance are still met and I should not have to pay anything once the $300 credit is used. Are you aware if Cloudflare reduces the bandwidth use when utilized as instructed here? That would be an awesome bonus to the ridiculously simple to setup SSL and DDOS protection that Cloudflare provides for free.

  8. Pingback: How Much Does it Cost to Build a WordPress Website? - SilentWP

Leave a Reply

Your email address will not be published. Required fields are marked *