Deploy Ghost Blog on Google Cloud with NGINX

Create a Compute Engine Instance

Login to your Google Cloud Console and go to Compute Engine.

Click on "Create Instance" at the top:

Deploy compute Engine instance

Name the instance.  I am naming my instance "ghost-blog".  Then go down to "Change" under Boot Disk.

Create Ubuntu Instance

I am changing the OS to Ubuntu 18.04 LTS and increasing the storage to 15GB.  After you make the changes click "Select".

ubuntu create ubuntu instance

Make sure you select "Allow HTTP" and "Allow HTTPS" then click "Create"

enable http and https



You can also use the Google Cloud command line to deploy this instance.  Make sure you change your "--project=" to your project name:

gcloud beta compute --project=XXXXXX-XXXX instances create ghost-blog --zone=us-central1-c --machine-type=e2-medium --subnet=default --network-tier=PREMIUM --maintenance-policy=MIGRATE [email protected].com --scopes=,,,,, --tags=http-server,https-server --image=ubuntu-1804-bionic-v20200923 --image-project=ubuntu-os-cloud --boot-disk-size=15GB --boot-disk-type=pd-standard --boot-disk-device-name=ghost-blog --no-shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring --reservation-affinity=any

We now have an Ubuntu Compute Instance deployed and ready to install the Ghost Blog platform.

I recommended that you create the DNS A record for your blog domain name. The A record points your domain name to the public IP address of your Google Cloud Instance.


Install Ghost Blog Prerequisites

Connect to the terminal of your instance by clicking the "SSH" button.

Connect to your compute instance via ssh

First, I like to add a user for the install of Ghost and its required components.  You can run it with the default account, but I do not recommend it.

Create a user:  sudo adduser ghostuser
Add the user to the sudo group:  sudo adduser ghostuser sudo

Create User for Install

Switch to that user:  su - ghostuser

change user to ghostuser

As always with a new Compute Instance, Update the OS:   sudo apt update;sudo apt upgrade

update Ubuntu

Install Node.js

First we must add the Node.js v10.x repository:   curl -sL | sudo -E bash -

node.js repository install

Now we can install Node.js:    sudo apt install nodejs

install node.js

We need to make sure of the Node.js version by running:   node -v

Check node.js version

We also need to verify the NPM version:  npm -v

check NPM version

Install MariaDB Database Server

I prefer MariaDB server, but if your preference is MySQL server feel free to use it.

Install MariaDB Server:   sudo apt install mariadb-server mariadb-client

MariaDB Server install

Verify that MariaDB is installed and running:    systemctl status mariadb

Verify MariaDB is running

Enable MariaDB to run at boot:   sudo systemctl enable mariadb

mariaDB start on server boot

Now, let's secure our MariaDB server by running:    sudo mysql_secure_installation

Secure MySQL Server

You will be prompted with questions to secure your installation.

secure Mysql questions

Create a database for Ghost

Log into MariaDB:   sudo mariadb -u root

MariaDB login server

Create the Ghost database.  Be sure to change "ghost_password" to a strong unique password.

create database ghost;
grant all privileges on ghost.* to ghost@localhost identified by 'ghost_password';
flush privileges;

Create Ghost Database

Install NGINX

Install NGINX:   sudo apt install nginx

Install NGINX


Install Ghost Blog

Install Ghost-CLI:   sudo npm install [email protected] -g

Install Ghost-CLI

Create a directory for our Ghost Blog:   sudo mkdir -p /var/www/ghost/

Make directory for Ghost Blog

Grant permissions to the directory:

sudo chown ghostuser:ghostuser /var/www/ghost
sudo chmod 775 /var/www/ghost

Ghost Directory Permissions

Install Ghost Blog into the directory:

cd /var/www/ghost/
ghost install

Ghost blog install

When prompted enter the following information:

Enter your blog URL:
Enter your MySQL hostname: localhost
Enter your MySQL username: ghost
Enter your MySQL password: ghost_password
Enter your Ghost database name: ghost

When prompted "Do you wish to set up Nginx?", say YES

When prompted "Do you wish to set up SSL?", say YES

Ghost Blog Setup Questions

When prompted "Do you with to set up Systemd?", say YES

When prompted "Do you want to start Ghost?", say YES


Ghost has started successfully.

ghost blog success


If you get the error "ER_TOO_LONG_KEY: Specified key was too long; max key length is 767 bytes"

Run sudo mysql -u root



Go to https://<yourdomain>/ghost

Ghost install is good

Configure NGINX for both www. and

By default

sudo nano /etc/nginx/sites-enabled/

edit nginx config file

Add the following lines:


Edit conf file

Remove your current SSL configuration

sudo rm /etc/nginx/sites-enabled/

delete ssl configuration

Now we need to install Certbot to renew the new certificates:    sudo apt install certbot python3-certbot-nginx

Install NGINX Certbot

Renew your certificates:    sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d,

After you have obtained your certificate, restart nginx:   sudo systemctl restart nginx


Leave a Reply