3 min read

How to Set up a Self-Hosted Ghost Blogging Platform

How to Set up a Self-Hosted Ghost Blogging Platform

Prerequisites

The officially recommended production installation requires the following stack:

  • Ubuntu 16.04, Ubuntu 18.04, Ubuntu 20.04 or Ubuntu 22.04
  • NGINX (minimum of 1.9.5 for SSL)
  • A supported version of Node.js
  • MySQL 8
  • Systemd
  • A server with at least 1GB memory
  • A registered domain name

Before getting started you should set up a working DNS A-Record from you domain, pointing to the server’s IP address. This must be done in advance so that SSL can be configured during setup.

A. Server Setup

Create New User

ssh root@your_server_ip
adduser <user>

Note: Using the user name ghost causes conflicts with the Ghost-CLI, so it’s important to use an alternative name.

usermod -aG sudo <user>
su - <user>

Install Nginx

sudo apt-get update
sudo apt-get upgrade

sudo apt-get install nginx
sudo ufw allow 'Nginx Full'

Install & Setup MySQL

sudo apt-get install mysql-server

sudo mysql -u root -p

CREATE DATABASE ghost;
CREATE USER 'ghost'@'localhost' IDENTIFIED WITH mysql_native_password BY '<Password>';
GRANT ALL ON ghost.* TO 'ghost'@'localhost';
FLUSH PRIVILEGES;
exit

Install Node.js

You will need to have a supported version of Node installed system-wide in the manner described below. If you have a different setup, you may encounter problems.

curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash
sudo apt-get install -y nodejs

B. Install Ghost-CLI

Ghost-CLI is a commandline tool to help you get Ghost installed and configured for use, quickly and easily. The npm module can be installed with npm or yarn.

sudo npm install ghost-cli@latest -g

C. Install Ghost

Create a directory

Ghost must be installed in its own directory, with a proper owner and permissions.

sudo mkdir -p /var/www/ghost
sudo chown <user>:<user> /var/www/ghost
sudo chmod 775 /var/www/ghost
cd /var/www/ghost

Run the install process

ghost install

? Enter your blog URL: https://example.com
? Enter your MySQL hostname: localhost
? Enter your MySQL username: ghost
? Enter your MySQL password: [hidden]
? Enter your Ghost database name: ghost
? Configuring Ghost
? Setting up instance
? Do you wish to set up Nginx? Yes
? Do you wish to set up SSL? Yes
? Do you wish to set up Systemd? Yes
? Do you want to start Ghost? Yes

Reload Nginx

sudo nginx -t
sudo systemctl reload nginx

D. Setup Ghost Admin

Reference

How to install & setup Ghost on Ubuntu 16.04, 18.04, 20.04 or 22.04
A full production install guide for how to install the Ghost professional publishing platform on a production server running Ubuntu 16.04, 18.04, 20.04 or 22.04.