Step-By-Step Guide to Starting Your Blogging Career with Ghost on GCP

Photo by Tony Schnagl from Pexels

Have you been thinking about blogging for a while but didn't know where to start?

There are tons of information out there on the internet, telling you how much the accomplished through blogging, perhaps you are keeping great ideas you want to share, or perhaps you want to raise capital for your future... but you just haven't got around to it yet.

We all love consuming videos and articles but getting to the work part is a real pain. It's hard when we don't know where to start, or we're unsure what niche we want to start writing about, or simply we procrastinate.

Whatever your situation is, let me encourage you, friends. There is a Korean saying that goes "By starting you're halfway there". Now, I want to take you halfway towards reaching your goal by walking you through how you can host your own blog, and get your blogging career started - like myself, this is my first blog post ;)

Ingredients

Blogging Platform: Ghost Blog

Hosting Service: GCP

Now if you've done some research into this area, you probably heard WordPress.

WordPress is just one way which you can start blogging. I don't really tend to fuss too much about the benefits of one or the other before I get started, I do a bit of research looking for key differentiators between platforms - I look at a couple of comparison websites, and if the opinion is similar, I pick whichever one I feel like going for.

I picked Ghost because I've used it at work before. See this link for details.

Now for those who are unfamiliar with the concept of WordPress and Ghost, to put it in simple terms they're free solutions you can use for many purposes; our focus is on managing our blog contents. For non-tech people, you can think of it as a wardrobe to organize your clothes, except it's digital so you can add new sections or drawers at your will.

But what good is a wardrobe if you don't have a house to put it in? Same with Ghost, there needs to be a computer where it can reside.

You can host a Ghost blog on your own computer by the way, except that nobody will be able to access it. Even if you do all the complicated networking shenanigans and make it available on the world wide web (www), you have to keep your computer running 24/7 to keep the blog online - Not very efficient is it?

So what you need is a server which is essentially a computer. When we talk about things like "the server is down", or "the server is slow" it just means we're having trouble with connecting to the computer somewhere on the planet. Except they're probably dedicated to being up all the time.

Now how do we get access to a server? You have probably heard of web hosting service providers like Bluehost.

Web hosting service providers essentially make life easier. They have everything ready, the servers, the databases. Most of them also make it easy for customers to host their own blog - from choosing their domain name and setting up a server in step by step manner. Customers can get started in no time.

But the thing is, you'll have to pay a decent sum of money up-front. Not to mention you'll have to pay for your domain registration after the free period ends.

But thanks to Google you can do all these things for little as $1 a month! With just a little effort to do things manually, you can do it too! just by following these steps.  

Step 1: Create a GCP Account

You can skip to Step 2 if you already have a GCP account.

With Google's GCP (Google Cloud Platform) you can create your own server. For those of you who don't know what GCP is, it's essentially an online platform where you can pick and choose what services you'd like to use from a wide range of options. We won't go into too much detail about that here, but just keep in mind that GCP offers free-tier services. It's good enough for starting bloggers like us.

Like I mentioned above, you'll need a computer. GCP lets you borrow a computer instance for free, which you'll use to host your blog. Google says it's free forever, so you can keep it running for as long as you like.

Cloud Computing Services | Google Cloud
Meet your business challenges head on with cloud computing services from Google, including data management, hybrid & multi-cloud, and AI & ML.

Click the above link to get into Google's Cloud platform. You'll reach a screen like below. Click Get Started for free, and go through the registration process.

From the screen that follows enter the following details

Step 1:

  • Country: Your Country
  • What best describes your organization or needs?: Personal Project

Tick the checkboxes under Terms and Conditions and Email Updates (Optional) then click Continue.

Step 2:

Enter your phone number and enter the verification code sent to your message to verify then click continue.

Step 3:

  • Account Type: Individual
  • Tax Information: N/A
  • Name and Address: Your address

Then click continue - There might be another form that you need to fill out to verify your personal information, but this depends on the country you're living in.  

It'll prompt you to add your payment information. Enter your credit/debit card details. If you decide to set up a domain name (this is your website URL), e.g. http://mywebsite.com - you'll be charged for the amount depending on how popular the domain name is, but for most of them, it'll be $1 USD/month.

If you've done everything correctly, you'll be redirected to a different page where you'll get a popup dialogue where you have to answer 4 simple questions.

Click Done once you've completed the questions. Congratulations, you've successfully created a GCP account.

Step 2: Setup Your Blog Domain

You can skip to Step 3 if you just want to play around with the blog by yourself and don't want a domain name to pay for. But I recommend you create one... I'm sure you can skip one lunchtime sushi to keep your blog running on a proper url for a year.

  1. Open the side menubar like the below screenshot.
  2. Scroll down and hover over Network services.
  3. Click Cloud Domains.

4. Click Enable when you're brought to a new screen. It'll take a moment to activate.

5. Once activated, you'll see a screen like below. Click Register Domain.

6. Search and pick the domain name you wish to create by clicking the shopping cart button on the right of the domain name you wish to add. Take note of the pricing, some are more expensive than others. When you're done, click continue.

7. In the next section, click Use Cloud DNS. If grayed out, Click Enable DNS Api hyperlink. The link will take you to a new screen. Once loaded, click Enable, then return to the previous screen.

If you've done it correctly, you should be able to do select Use Cloud DNS now, select it, then choose New zone: <selected domain name> under Cloud DNS zone dropdown, then click continue.

8. Click Continue from the Privacy protection section

9. From the next section, enter your Contact details then click Register.

10. If you see a screen like above, you've successfully set up your own domain.

Step 3. Create a Virtual Machine (Hosting Server)

  1. Open the left sidebar > Find Compute Engine > Click VM instances like the below screenshot. Click Enable if this is your first time entering this screen.

2. Once activated, you'll see a screen like below. Click Create Instance

Hold On! Please follow the following instructions very carefully. Wrong set-up could mean you could be billed an extra amount by creating a non-free-tier instance or you could be creating an instance that doesn't work for the follow-on instructions.

Main Configuration

3. Make sure to configure your instance as follows

  • Give a Name for your instance, in this example, we'll name it 'my-blog'.
  • Set Region as us-west1 (Oregon). Zone can be anything.
  • Under the Machine Configuration section, make sure the General-purpose tab is selected.
  • Set Series to E2.
  • Set Machine type to e2-micro.
  • We will come back to the Boot disk section, but for now, scroll down to the Firewall section, and make sure Allow HTTP traffic and Allow HTTPS traffic are checked.
  • Scroll back up to the Boot disk section and click Change. It'll bring up a window like below.
  • From the Public images tab, under Operating System select Ubuntu.
  • Under Version, select Ubuntu 21.04 (This could not be available depending on the time you're reading it, then I'd recommend going for the latest version).
  • Select Standard persistent disk under Boot disk type.
  • Set 30 under Size (GB).
  • Click the Select button at the bottom to return from the popup.
Please make sure that your configuration looks exactly like the above screenshot, or at least closely resembles it, if some configurations were not available because you're living in the future.

Don't worry about the billing message on the top right side of the screen. You won't be billed if you've set up everything correctly. But it is possible that the free-tier configuration could have changed since this article was published, so make sure to check this link. Go to Compute Engine section for free-tier information on VMs to double-check that things haven't changed.

  • Once you're done, click Create. It'll take a few moments for the new instance to be activated.
Please copy the External IP address from the above screen, as we will be using it in the following section.  

Step 4. Configure Domain To Your Server

You may skip to Step 5 if you've skipped Step 3 (creating your domain), as this section is irrelevant.

  1. Search "cloud dns" from the search bar, and click the first search result. Cloud DNS. (This is an alternative method of accessing service menus to using the sidebar. It's a convenient feature if you can memorize the service names).

2. Click on your zone name, which should be similar to the domain name you registered earlier. There should only be one if this is your first time accessing this page. (Mine is different because I created it manually)

3. Click ADD RECORD SET

4. Under IPv4 Address 1* paste the copied External ID address of the VM that we created in the previous section then click Save.

5. Set Up Your Blog on The Server

Click the SSH button from Compute Engine menu.

  1. Update the package list
sudo apt-get update
Step 1

2. Upgrade the package list

sudo apt-get upgrade
Step 2

3. Install Required Packages. Input "Y' and press Enter when prompted for confirmation.

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release \
    software-properties-common
Step 3

4. Do Docker operations

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

For Below: Press Enter when prompted

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu groovy stable"

For Below: Input "Y" and press Enter when prompted for confirmation.

sudo apt-get install docker-ce docker-ce-cli containerd.io

If you have successfully set up everything, type the below command to confirm that docker was installed. If unsuccessful, you may get an error message.

sudo docker --version
Error Message on unsuccessful installation:
sudo: docker: command not found

5. Get the latest ghost image from docker.

sudo docker pull ghost:latest

6. For this step, I suggest that you copy it to your own text editor first and replace <your_domain_or_external_IP> with the domain or external IP you've created earlier. For mine, it would be bitesizedlearnings.com or 34.145.110.117.

Running the below script will create a config file that contains the Ghost Blog configuration information.  

mkdir ghost_blog

echo '{
  "url": "http://<your_domain_or_external_IP>",
  "server": {
    "port": 2368,
    "host": "0.0.0.0"
  },
  "database": {
    "client": "sqlite3",
    "connection": {
      "filename": "/var/lib/ghost/content/data/ghost-blog.db"
    }
  },
  "mail": {
    "transport": "Direct"
  },
  "logging": {
    "level": "info",
    "transports": ["file", "stdout"]
  },
  "paths": {
    "contentPath": "/var/lib/ghost/content"
  }
}' >> ghost_blog/config.json

Running the below prompt will create a script that runs the blog.

echo '# Set path variables
DATA_DIR="$PWD/ghost_blog"
CONTAINER_NAME="ghost_blog"

docker run \
-d \
--restart=always \
-p 80:2368 \
-e url="http://<your_domain_or_external_IP>" \
-v $DATA_DIR/content:/var/lib/ghost/content \
-v $DATA_DIR/config.json:/var/lib/ghost/config.production.json \
--name $CONTAINER_NAME \
ghost' >> run.sh
\

Don't forget to replace <your_domain_or_external_IP> with the domain name you've created in section 2 or your instances external IP.

7. Run the below command to kick start your blog!

sudo sh ./run.sh

8. Wait a moment for the Blog to start up, then try putting in the domain you created earlier e.g. http://your_domain_or_ip/, then you'll see a screen like below!

Note that its http, not https

9. to access the admin page where you can create articles, put in /ghost suffix http://your_domain/ghost.

Click Create your account

Fill in the form then click Last step: Invite staff users ->

Click I'll do this later at the bottom if you don't have anyone to add as a staff user.

This will take you to the Ghost blog dashboard where you can create your own posts! There are default articles that come with it, play around with it, have fun! And enjoy blogging!!


Please feel free to ask me any questions if you're stuck, leave a comment below, and perhaps someone else who's experiencing the same problem can have their problem solved as well. Looking forward to interacting with you all!

Kyle Jung

Kyle Jung