How to Start a Self-Hosted Ghost CMS Blog for Personal or Tech Use
Ghost is a content management system (CMS) designed to manage and publish blog posts and associated image files as web pages. Popular CMS platforms include well-known options like WordPress. In this article, we’ll outline the steps to self-host Ghost CMS and launch your own blog.
Ghost CMS Features
Ghost is an open-source Headless CMS, which differs from traditional CMS platforms by separating the backend and frontend, with communication occurring via API. This decoupled structure allows for flexibility in frontend technology, making it possible to use popular frameworks like React, Vue.js, and Angular, or static site generators such as Gatsby and Next.js. Personally, I find Ghost CMS particularly appealing compared to other Headless CMS options like Contentful, due to its open-source nature. I also appreciate the simplicity and ease of use of Ghost’s default UI.
Preparation
Before running Ghost on a self-hosted setup, there are a few preliminary steps to complete. While server setup steps will be detailed later, here’s a checklist of other essential preparations. Each item is explained below:
- Prepare a server environment
- Obtain a custom domain
- Configure DNS settings
Server environment
First, you’ll need to set up a server environment to run Ghost. According to the official documentation, a minimum of 1GB of RAM is required, though having additional memory is recommended for smoother operation. The recommended operating system for Ghost is Ubuntu.
Your own domain
To publish your blog, you’ll need to secure a domain. Choose a preferred domain and register it through a reliable domain registrar. If you’re setting up a technical or marketing blog for a company, using a subdomain of an existing domain could also be a good option.
DNS Settings
To use your domain, you’ll also need to configure DNS settings. Typically, you can set up records within the DNS provided by your domain registrar. For example, on this blog, records are configured as follows: enter your domain name in the HOST field, and your server’s IP address in the ANSWER section.
It may take a little time for the DNS changes to take effect, so you can relax with a coffee while you wait. You can use the dig command to check if the records have propagated. Be sure to specify the domain name you added to the DNS records.
$ dig example.com
Set Up Guide
Below are the steps to set up Ghost CMS on your server. Here, we’ll assume you’re using Ubuntu, as it’s the recommended operating system. In my setup, I’m specifically using Ubuntu 20.04 LTS. If you need to use a different OS, please adapt the instructions accordingly. The setup process is largely automated using a tool called ghost-cli, which we’ll use here.
1. Update apt package
If it has already been updated, there is no need to run it.
$ sudo apt-get update
$ sudo apt-get upgrade
2. Create user for operations
The ghost-cli tool, as noted in the documentation, does not allow execution as the root user. Therefore, you’ll need to create a dedicated user for this process. Replace <username>
with your preferred username.
$ adduser <username>
$ usermod -aG sudo <username>
The created user will be used thereafter.
$ su - <username>
3. Install node.js
To install ghost-cli via npm, you’ll first need to install Node.js. Note that some Node versions are supported while others are not, so please check the official Supported Node Versions for compatibility. In this guide, I’ll be using Node version 18.12.1. I use a tool called asdf to install Node.js, but feel free to use any installation method you prefer.
$ git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.12.0
$ . "$HOME/.asdf/asdf.sh"
$ asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
$ asdf install nodejs 18.12.1
$ asdf global nodejs 18.12.1
4. Install ghost-cli
he ghost-cli tool simplifies the setup and management of Ghost. As of the time of writing, the latest version of ghost-cli is 1.24.2.
$ npm install ghost-cli -g
5. Install Nginx
Ghost uses Nginx as a web server, so install this as well.
$ sudo apt-get install nginx
6. Install MySQL
Install MySQL as a DB for storing articles and other data.
$ sudo apt-get install mysql-server
After installation, change the password for the MySQL root user. In the following, change the password
part of SQL to any value you like.
$ sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
quit
7. Install Ghost
To install Ghost using ghost-cli, start by creating the installation directory. Replace <dirname>
with your preferred directory name and <username>
with the working user name you’re using.
$ sudo mkdir -p /var/www/<dirname>
$ sudo chown <username>:<username> /var/www/<dirname>
$ sudo chmod 775 /var/www/<dirname>
Next, use the ghost install
command to set up Ghost. You’ll be prompted with several interactive questions, and you should respond as indicated in the comments below. For <url>
, specify the domain you obtained earlier (e.g., https://nctn.me
for this blog). For <password>
, enter the password set in the previous MySQL configuration, and for <email>
, enter your own email address.
$ cd /var/www/<dirname>
$ ghost install
blog url: <url>
mysql server: 127.0.0.1
mysql username: root
mysql password: <password>
ghost db name: <db name>
set up "ghost" mysql user: no
set up nginx: yes
set up ssl: yes
email address for let's encrypt: <email>
set up systemd: yes
start ghost: yes
8. Access your own Ghost web site
At this point, the web server should be up and running. Finally, confirm that you can access the website by navigating to https://<domain>/ghost
, where you can access the admin panel. With this, the setup of Ghost is complete.
For this blog, I’m using a theme called Thesis. It’s a paid theme, but it’s well-optimized for SEO and offers excellent functionality. If you’re interested, feel free to try it out. You can check the demo and details on the official page below.
Discussion