How to Install & Setup Ghost on Ubuntu

How to Install and Setup Ghost on Ubuntu

Have you ever thought about starting an elegant and minimalistic blog and found it costly to buy membership plans from the blogging platforms like Ghost? Well, I thought that too and figured out a way to self-host a blog using the Ghost blogging platform for as low as 5USD per month with Skysilk. In this blog post, we will cover how to install and setup Ghost on Ubuntu and installing Ghost-CLI.

There are a few reasons to consider installing and setting up Ghost on Ubuntu as your blogging platform. To run it efficiently and to maximize these benefits, keep these requirements in mind.

Ghost features

  • Unlike WordPress, Ghost uses Node.js instead of PHP.
  • Ghost is an open source software 
  • It offers tons of integrations such as Slack, Stripe, Google analytics and lots more
  • SEO meta tags and social media optimization is an inbuilt feature 
  • Is a very lightweight and fast blogging platform

Requirements

  • A VPS server with >1 GB RAM
  • Ubuntu 16.04 or 18.04
  • Nginx
  • A supported version of Node.js
  • MySQL
  • A domain name pointing its A records to your VPS server’s public IP address

SETUP DNS

You should add an “AAAA” record in your DNS manager if you have a server that only has an IPv6. In case you also have IPv4, add an A record in your DNS manager. Below is the example of DNS records, you can replace them with your server IP addresses.

A @ 100.100.100.100

AAAA @ 2001:0db8:85a3:0000:0000:8a2e:0370:7334

Login to SSH with root

ssh root@your-server-ip

Install Nginx

Nginx is one of the essential requirements to be able to install Ghost blogging platform on your VPS server. Usually we install Nginx on our VPS server followed by server blocks setup. But in this process, we need not set up server blocks right now. 

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install nginx

Read more: Apache vs Nginx | Choosing the Best Open Source Web Server for You

Setup Database

Ghost platform requires MySQL server on your VPS to be able to function. You need to install the MySQL server first and then setup the database, database user and grant the user permissions to use that database.  

  • MySQL server will be installed
sudo apt-get install mysql-server
  • Essential setup after installing MySQL server on your VPS
sudo mysql_secure_installation
  • Login to your MySQL server with the root user
sudo mysql -u root -p
  • Replace ‘ghostdb’ with your preferred database name
create database ghostdb;
  • Replace ‘ghostusr’ with your desired username and ‘ghostpassword’ with your strong password. If you enable the validate password module in the secure mySQL installation, you will have to make sure that your password complies with your password policy.
create user ‘ghostusr’@’localhost’ identified by ‘ghostpassword’;
  • Next, Give permissions to the newly created user to the database with the following command.
grant all on ghostdb.* to ‘ghostusr’@’localhost’;
flush privileges;
exit

Install Node.js

As I mentioned before, the Ghost blogging platform uses node.js. Therefore, you need to install the supported version of Node. 

You can check all the supported versions of Node.js for Ghost here.

Before using curl command, make sure that it is already installed on your server. 

curl -I server-hostname

If the command returns the server’s configuration details, skip the next command. 

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

Install Ghost CLI

Ghost-CLI is a command-line interface that lets you perform a wide range of actions in the Ghost platform installation. You can easily install, uninstall and troubleshoot your ghost instance on your server using the Ghost-CLI.

sudo npm install ghost-cli@latest -g

Setup the installation directory

Now you have installed the required stack to install Ghost blogging platform. However, here you will decide where you want ghost to keep the files.

  • Replace ghostsecure with the directory name you want for your Ghost installation.
sudo mkdir /var/www/ghostsecure
sudo apt-get install -y nodejs
sudo chmod 775 /var/www/ghostsecure
cd /var/www/ghostsecure
  • A properly configured Ghost install may not work if you fail in giving the right permissions. Use below command to set the permissions.
chown -R www-data:www-data /var/www/ghostsecure

Install Ghost

ghost install

When you run the above command, it will ask you a few questions to set up everything for you. 

Blog URL: https://yourdomain.com replace with your blog’s domain name

SQL hostname: localhost

SQL user: ghostusr replace with your database username

SQL password: ghostpassword replace with your database password

Setup Nginx: Y

SSL: Y

SSL email: [email protected] replace with your email address

Systemd: Y

Start Ghost?: Y

You need not worry about the SSL certificate for your ghost blog because the ghost-cli will automatically create an SSL certificate for you. This SSL certificate is configured using Letsencrypt. You need to make sure that you type in the right email address because your server will use that email to send you notifications if anything happens with your SSL certificate; such as renewals.

On the other hand, Nginx server blocks will also be set up when you say yes to setup Nginx during the setup process.

Read more: How to Host a Minecraft Server on Ubuntu

Conclusion

Installing and setting up Ghost on Ubuntu is fairly simple. After a successful installation and setup of the Ghost blogging platform on Ubuntu, you should be able to set up the admin user by visiting yourdomain.com/ghost. Furthermore, after installing Ghost-CLI, you can now visit your website, change the theme, customize it and start blogging on one, of the most minimalistic and elegant blogging platforms.

About the author: Vashishtha Kapoor is a Digital Marketing enthusiast and has over 5 years of experience in SEO, PPC, Website Management and WordPress development. Vashishtha writes about WordPress customizations, website designing, technology trends, and ad-tech topics.

Share this post with your friends