Introduction
Ghost is a lightweight, open-source Content Management System (CMS) and blogging platform built with Node.js. It is customizable and has many pre-built themes available. In this article, you'll learn how to install Ghost CMS on Ubuntu 20.04.
Prerequisites
Deploy a fully updated RCS Ubuntu 20.04.
Create a non-root user with sudo access.
Create a DNS "A" record, such as
ghost.example.com
, that resolves to the IP address for your server.Install MySQL on your Ubuntu server.
1. Create the Ghost Database
SSH to the server as your non-root user with sudo access.
Login to
mysql
.$ sudo mysql -u root -p
Create a database named
ghost
.CREATE DATABASE ghost;
Create a database user named
ghost
.CREATE USER 'ghost'@'localhost' IDENTIFIED WITH mysql_native_password BY 'StrongPassword';
Grant all privileges of the
ghost
database to the userghost
.GRANT ALL ON ghost.* TO 'ghost'@'localhost';
Flush privileges for the changes to take effect.
FLUSH PRIVILEGES;
Exit MySQL.
exit
2. Install Nginx
Install Nginx.
$ sudo apt-get install nginx -y
Enable Nginx server to start on boot.
$ sudo systemctl enable nginx
Allow firewall for both HTTP and HTTPS connections.
$ sudo ufw allow 'Nginx Full'
3. Install Node.js
Add the NodeSource APT repository for Node 14.
$ curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash
Install Node.js.
$ sudo apt-get install nodejs -y
4. Install Ghost
Install Ghost-CLI.
$ sudo npm install ghost-cli@latest -g
Create a directory
/var/www/ghost/
.$ sudo mkdir -p /var/www/ghost/
Set ownership of the directory to the current user account.
$ sudo chown -R $USER:$USER /var/www/ghost/ $ sudo chmod 775 /var/www/ghost
Go to
/var/www/ghost/
directory.$ cd /var/www/ghost/
Install Ghost.
$ ghost install
Answer the prompts as shown.
? Enter your blog URL: https://ghost.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 Systemd? Yes ? Do you want to start Ghost? (Y/n) Y
Navigate to your Ghost admin portal. For example:
https://ghost.example.com/ghost/