DEV Community

aaftabkhan
aaftabkhan

Posted on • Originally published at devsecopspros.com on

Hosting your own blog using Ghost CMS (an excellent alternative to WordPress)

For a long time now I was planning to host my own tech blog, but managing multiple WordPress blog over the years I was sure of one thing that it is not going to be my CMS for sure.

I played with Hugo (an open-source static site generators) & Ghost for sometime and ultimately ended up choosing Ghost for my blog.

Sure!, there are some pros and cons with both of them and the first one would be, hosting cost. As being a static site Hugo will be much cheaper to host compared to Ghost which is a platform built on a modern Node.js technology stack.

Let me give you a complete walkthrough of the entire setup.

Prerequisites

To follow this tutorial, you will need the following:

  • Your own domain name.
  • A Linux server.
  • Domain mapped to your Linux server IP.

My preferred linux server is AWS EC2.

AWS offers free-tire for new users where you'll get a t2-micro(1 vCPU & 1 GB Memory) instance free for a year.

Which is more than enough for a new blog.

Step 1- Install Nginx webserver

First, update your existing list of packages:

sudo apt-get update

Next, install Nginx

sudo apt-get install nginx -y

Step 2- Install MySQL Server

Ghost CMS uses MySQL as its backbone database.

MySQL 5.5, 5.6, or 5.7 (not >= 8.0)

sudo apt-get install mysql-server -y

Step 3- Configure MySQL

# To set a password, run
sudo mysql

# Now update your user with this password
# Replace 'password' with your password, but keep the quote marks!
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

# Then exit MySQL
quit

Step 4- Install Node.js

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash

sudo apt-get install -y nodejs

Step 5- Install Ghost

sudo npm install ghost-cli@latest -g

Step 6- Create a directory for Ghost

# We'll name ours 'ghost' in this example; you can use whatever you want
sudo mkdir -p /var/www/ghost

# Replace <user> with the name of your user who will own this directory
sudo chown <user>:<user> /var/www/ghost

# Set the correct permissions
sudo chmod 775 /var/www/ghost

Step 7- Run Ghost

# Navigate into it
cd /var/www/ghost

ghost install

##It will prompt you for some inputs

# Enter your blog URL, for our example we will use foobar.com
# In case you want your blog on a subdomain, enter <subdomain.foobar.com> (Make sure subdomain is mapped to IP address of server)

? Enter your blog URL: foobar.com

? Enter your MySQL hostname: localhost 
#Since our MySQL is installed on same server its localhost

? Enter your MySQL username: root

? Enter your MySQL password: [password]
#your root password created in Step 3

? Enter your Ghost database name: ghost_prod

? Do you wish to set up "ghost" mysql user? No 

? Do you wish to set up Nginx? Yes

? Do you wish to set up SSL? Yes

? Enter your email (For SSL Certificate): your_email_address

? Do you wish to set up Systemd? Yes

? Do you want to start Ghost? Yes

Congratulation...

Your blog is up and running

Visit https:///ghost/ to setup your admin user.

Top comments (0)