LinuxTutorialsUbuntu

How To Install Ghost on Ubuntu 20.04 LTS

Install Ghost on Ubuntu 20.04

In this tutorial, we will show you how to install Ghost on Ubuntu 20.04 LTS. For those of you who didn’t know, Ghost is a lightweight, open-source Content Management System (CMS) and blogging platform built with Node.js. It has full support for Markdown and provides an easy-to-use web interface for administration purposes.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of Ghost CMS on Ubuntu 20.04 (Focal Fossa). You can follow the same instructions for Ubuntu 18.04, 16.04, and any other Debian-based distribution like Linux Mint.

Prerequisites

  • A server running one of the following operating systems: Ubuntu 20.04, 18.04, 16.04, and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Ghost on Ubuntu 20.04 LTS Focal Fossa

Step 1. First, make sure that all your system packages are up-to-date by running the following apt commands in the terminal.

sudo apt update
sudo apt upgrade

Step 2. Installing Node.Js.

Run the following command to install Node.js on your system:

curl -sL https://deb.nodesource.com/setup_14.x | bash -
sudo apt install nodejs

Once the installation is finished, verify the Node and NPM versions using the following command:

node -v
npm -v

Step 3. Installing the LEMP stack.

A Ubuntu 20.04 LEMP server is required. If you do not have LEMP installed, you can follow our guide here.

Step 4. Configuring MariaDB.

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:

mysql_secure_installation

Configure it like this:

- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y

Next, we will need to log in to the MariaDB console and create a database for the Ghost. Run the following command:

mysql -u root -p

This will prompt you for a password, so enter your MariaDB root password and hit Enter. Once you are logged in to your database server you need to create a database for Ghost installation:

MariaDB [(none)]> CREATE DATABASE ghostdb;
MariaDB [(none)]> CREATE USER 'ghostuser'@'localhost' IDENTIFIED BY 'your-strong-password';
MariaDB [(none)]> GRANT ALL ON ghostdb.* TO 'ghostuser'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Step 5. Installing Ghost on Ubuntu 20.04.

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

npm install -g ghost-cli@latest

Verify the installed version of Ghost CLI with the following command:

ghost version

Next, create a separate user for Ghost:

adduser user-id
adduser user-id sudo
adduser user-id www-data

Then, log in with user-id and create a directory for Ghost with the following command:

su - user-id
sudo mkdir /var/www/ghost

Set ownership of the directory to the current user account:

sudo chown -R www-data:www-data /var/www/ghost
sudo chown -R www-data:www-data /var/www/
sudo chmod 775 /var/www/ghost
sudo setfacl -R -m u:user-id:rwx /var/www/ghost/

After that, change the directory to ghost and install the Ghost using the following command below:

cd /var/www/ghost
ghost install

Output:

? Enter your blog URL: https://ghost.idroot.us
? Enter your MySQL hostname: localhost
? Enter your MySQL username: ghostuser
? Enter your MySQL password: [hidden]
? Enter your Ghost database name: ghostdb
? Configuring Ghost
? Setting up instance
+ sudo useradd --system --user-group ghost
+ sudo chown -R ghost:ghost /var/www/ghost/content
? Setting up "ghost" system user
? Setting up "ghost" mysql user [skipped]
? Do you wish to set up Nginx? Yes
+ sudo mv /tmp/ghost-idroot-us/ghost.idroot.us.conf /etc/nginx/sites-available/ghost.idroot.us.conf
+ sudo ln -sf /etc/nginx/sites-available/ghost.idroot.us.conf /etc/nginx/sites-enabled/ghost.idroot.us.conf
+ sudo nginx -s reload
? Setting up SSL [skipped]
? Do you wish to set up Systemd? Yes
+ sudo mv /tmp/ghost-idroot-us/ghost_ghost-idroot-us.service /lib/systemd/system/ghost_ghost-idroot-us.service
+ sudo systemctl daemon-reload
? Setting up Systemd
+ sudo systemctl is-active ghost_ghost-idroot-us
? Do you want to start Ghost? (Y/n)

Step 6. Set up HTTPS.

Now we secure Ghost with Let’s Encrypt SSL:

sudo apt install certbot python3-certbot-nginx

Next, run the following command to download the Let’s Encrypt SSL and configure Nginx to use those certificates:

sudo certbot --nginx -d ghost.idroot.us

If the test is successful, reload Apache for the change to take effect:

nginx -tsudo systemctl restart nginx

Now, you can verify the Ghost website with the following command:

ghost ls
sudo systemctl status ghost_ghost-idroot-us

Step 7. Accessing Ghost Web Interface.

Once successfully installed, open your web browser and access the Ghost admin interface using the URL https://ghost.idroot.us/ghost/. You should see the following page:

Install Ghost on Ubuntu 20.04

Congratulations! You have successfully installed Ghost. Thanks for using this tutorial for installing Ghost CMS on Ubuntu 20.04 LTS Focal Fossa system. For additional help or useful information, we recommend you check the official Ghost website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button