1. Home
  2. Linux

How To Install Ghost On Ubuntu Server

Want to set up a blog on your Linux web server but what something a little simpler and lighter than WordPress? Consider installing Ghost instead. It’s a super fast, fully open source blogging platform that focuses on simplicity and ease of use. Please understand that though we’re focusing on Ubuntu sever in this tutorial, you can install Ghost on virtually any Linux server distribution. The only requirements are a LEMP stack (Linux, Nginx MySQL and PHP), and the Node.JS package manager to run the Ghost-Cli installation tool.

Creating A User For Ghost

It’s not safe to manage Ghost on the server with the root user. Instead, it’s much safer to set up a user specifically to control and manage the Ghost software on the system. To set up the user, open up a terminal on the server and log into the root user with su.

From here, use the adduser command to add a new user to Ubuntu.

adduser ghost-admin

Using the usermod tool, add ghost-admin to the sudo group. This will ensure that the ghost-admin account we just created can access and execute root level commands via sudo.

usermod -aG sudo ghost-admin

Using passwd, set ghost-admin up with a new, secure password.

passwd ghost-admin

After setting up the password, log out of root and into ghost-admin with:

su ghost-admin

Installing LEMP (Linux, Nginx MySQL and PHP)

Ghost runs best with a LEMP stack, rather than a “LAMP” setup. This means that the installer, as well as the developers would prefer you use Nginx as your webserver, rather than Apache2.

Note: it is possible to install Ghost with Apache2, but it will not be covered in this tutorial. Refer to the official Ghost blog documentation for instructions.

If you’ve already got a LAMP (Linux, Apache2, MySQL and PHP) setup on Ubuntu server, most of the tools you’ll need to run this software are already on the system. All that is required, is replacing Apache2 with Nginx. To do this, enter:

sudo -s

systemctl stop apache2

apt remove --purge apache2

Then, simply replace it with Nginx.

sudo -s

apt install nginx

systemctl enable nginx

systemctl start nginx

ufw allow 'Nginx Full'

Don’t have any web tools at all? Enter the command below to start the installation of a LAMP stack. Doing this will take you through setting up things such as MySQL, and etc. Once finished, follow the instructions above to purge the Apache2 in favor of the Nginx web server.

sudo apt install lamp-server^

Note: during the LAMP setup, MySQL will ask the user to set a root password. Set one, and make sure it is secure. This is required, for Ghost-CLI to function properly.

Installing Node.JS

The Ghost blogging platform runs with the help of Node.JS. As a result, users will need to install the NodeSource APT repo.

Note: make sure you have the curl package installed on the system before continuing.

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash

After using curl, use the Ubuntu package management software to install NodeJS to Ubuntu server.

Note: be sure to also install all system updates to Ubuntu server before attempting to grab NodeJS, to ensure that everything runs smoothly.

sudo apt-get install nodejs

Installing Ghost-Cli

The Ghost Blogging platform is built upon the NodeJS set of tools. As a result, it ships an NPM version of Ghost that lets users easily, and automatically install (and uninstall) their software to any version of Linux that capable of running NPM/NodeJS and Nginx.

To get started, make sure that NPM itself is installed on Ubuntu. You’ll need to do this step because NodeJS often isn’t included with NPM, and they are separate packages that work together.

sudo apt install npm

Then, using the Node npm tool, install the latest version of the ghost-cli package:

sudo npm i -g ghost-cli

Using Ghost-Cli To Install Ghost

All of the software required to install Ghost is on the system. Now all that is left is to actually grab the latest version of it and get it running correctly. To do that, we first need to make a directory in the root web server folder. For Nginx, this is /var/www/.

Using the user we created earlier, create a ghost folder in the web directory.

sudo mkdir -p /var/www/ghost/

Use CD to enter the new Ghost directory. It is important that the shell is directly working out of /var/www/ghost, or the ghost-cli tool will refuse to work correctly.

cd /var/www/ghost/

Launch Ghost-Cli. This tool is automatic, and will ask various questions. Launch the initial setup with:

sudo ghost install

The first question that Ghost-Cli will ask is “what is your blog URL”. Enter your domain name in the prompt, and press enter to continue.

Ghost-Cli will then ask the user to input some MySQL information. Enter “localhost” as the host-name. Next, enter the root MySQL password you set up earlier, and the root username. Follow the prompts in the installer, and soon Ghost will be up and running on your server.

After the cli installer is complete, go to https://yourserverdomainname/ghost to set up and post on your new blog.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.