Linux Commands and Scripts

How to Install Ghost 3.34.4 on Ubuntu 18.04

In this article, we will see how it is easy to install Ghost 3.34.4 on Ubuntu 18.04.

Ghost is an Open Source application which allows us to write and publish our own blog, giving you the tools to make it easy and even fun to do. It’s simple, elegant, and designed so that we can spend less time making our blog work and more time blogging.

If you’re comfortable installing, maintaining and updating your own software, this is the place for you. By the end of this guide you’ll have a fully configured Ghost install running in production using MySQL.

Prerequisites

  • Dedicated server or VPS with Ubuntu 18.04 installed
  • NGINX (minimum of 1.9.5 for SSL)
  • A supported version of Node.js
  • MySQL 5.5, 5.6, or 5.7 (not >= 8.0)
  • Systemd
  • A server with at least 1GB memory
  • A registered domain name

Before you start with the installation, you should setup an A record of the domain that you plan to use.

Let’s get started with the installation.

1. Add a new user

To install Ghost, we need to add normal user with root privileges.

# adduser -aG sudo user

Note: Do not use username as a ghost it gets cause conflicts with the Ghost-CLI.

Then log in as the new user

# su – user

2. Keep the server up to date

# sudo apt-get update -y

# sudo apt-get upgrade -y

3. Install Nginx

Ghost uses an NGINX server and the SSL configuration requires NGINX 1.9.5 or higher.

# sudo apt-get install nginx -y

Start and enable Nginx

# sudo systemctl start nginx

# sudo systemctl enable nginx

Allow Nginx in firewall

# sudo ufw allow ‘Nginx Full’

4. Install MySQL

Next, we’ll need to install MySQL to be used as the production database.

# sudo apt-get install mysql-server -y

Start MySQL service

# sudo systemctl start mysql

# sudo systemctl enable mysql

5. Set password to root user in MySQL

To perform this task, switch to root user.

# mysql

Replace ‘password’ with your password, but keep the quote marks!

ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’;

quit

Now, switch back to normal user.

6. 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.

Add the NodeSource APT repository for Node 12

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

Install Node.js

# sudo apt-get install -y nodejs

7. 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.

# sudo npm install ghost-cli@latest -g

Once installed, you can always run ghost help to see a list of available commands.

8. Install Ghost

Once your server is correctly setup and the ghost-cli is installed, you can install Ghost. The following steps are the recommended setup. If you would prefer more fine-grained control, the CLI has flags and options that allow you to break down the steps and customise exactly what they do.

Note: Setup may broke if you install Ghost in /root or /home/user. Always use a custom directory with properly configured permissions.

# sudo mkdir -p /var/www/ghost

Modify ghost to whatever you want to use name as a web directory.

Replace user to your normal username.

# sudo chown user:user /var/www/ghost

Set the correct permissions

# sudo chmod 775 /var/www/ghost

Then navigate into it

# cd /var/www/ghost

Now, start the installation process using following command:

# ghost install

Once the install is finished you’ll be able to access your new site and navigate to /ghost to access Ghost Admin.

During the installation process, you may asked few questions lik

Blog URL

Enter the exact URL your publication will be available at and include the protocol for HTTP or HTTPS. For example, https://example.com. If you use HTTPS, Ghost-CLI will offer to set up SSL for you. Using IP addresses will cause errors.

MySQL hostname

This determines where your MySQL database can be accessed from. When MySQL is installed on the same server, use localhost (press Enter to use the default value). If MySQL is installed on another server, enter the name manually.

MySQL username / password

If you already have an existing MySQL database enter the the username. Otherwise, enter root. Then supply the password for your user.

Ghost database name

Enter the name of your database. It will be automatically set up for you, unless you’re using a non-root MySQL user/pass. In that case the database must already exist and have the correct permissions.

Set up a ghost MySQL user? (Recommended)

If you provided your root MySQL user, Ghost-CLI can create a custom MySQL user that can only access/edit your new Ghost database and nothing else.

Set up NGINX? (Recommended)

Sets NGINX up automatically enabling your site to be viewed by the outside world. Setting up NGINX manually is possible, but why would you choose a hard life?

Set up SSL? (Recommended)

If you used an https Blog URL and have already pointed your domain to the right place, Ghost-CLI can automatically set up SSL for you using Let’s Encrypt. Alternatively you do this later by running ghost setup ssl at any time.

Enter your email

SSL certification setup requires an email address so that you can be kept informed if there is any issue with your certificate, including during renewal.

Set up systemd? (Recommended)

systemd is the recommended process manager tool to keep Ghost running smoothly. We recommend choosing yes but it’s possible to set up your own process management.

Start Ghost?

Choosing yes runs Ghost, and makes your site work.

That’s it. Ghost was installed successfully! To complete setup of your publication, visit the blog URL, the one you have mentioned during the installation process.

In this article, we have seen how it is easy to install Ghost 3.34.4 on Ubuntu 18.04.

Related Articles