Prerequisites

  • Ubuntu 16.04 or Ubuntu 18.04
  • NGINX (minimum of 1.9.5 for SSL)
  • Node.js (8.x recommended at time of writing. For more info see official docs)
  • MySQL 5.5, 5.6, or 5.7 (not >= 8.0)
  • 1 GB memory
  • Hostname with DNS configured appropriately, i.e.
$ nslookup www.musingitoutloud.com
Server:		127.0.0.53
Address:	127.0.0.53#53

Non-authoritative answer:
Name:	www.musingitoutloud.com
Address: 104.24.113.248
Name:	www.musingitoutloud.com
Address: 104.24.112.248

Ubuntu Server Build

  • 18.04 at time of writing. (Stick to LTS releases.)

Base OS

$ sudo adduser ghostadmin
$ usermod -aG sudo ghostadmin
$ sudo su - ghostadmin
$ sudo apt update
$ sudo apt upgrade
$ sudo ufw allow ssh
$ sudo ufw allow http
$ sudo ufw allow https
$ sudo ufw enable

$ nmap -p80,443 www.musingitoutloud.com

Starting Nmap 7.60 ( https://nmap.org ) at 2019-01-02 10:30 AEST
Nmap scan report for www.musingitoutloud.com (104.24.112.248)
Host is up (0.00031s latency).
Other addresses for www.musingitoutloud.com (not scanned): 104.24.113.248 2606:4700:30::6818:71f8 2606:4700:30::6818:70f8

PORT    STATE SERVICE
80/tcp  open  http
443/tcp open  https

Nmap done: 1 IP address (1 host up) scanned in 13.12 seconds

Software

NGINX

$ sudo apt-get install nginx

MySQL

$ sudo apt-get install mysql-server
$ sudo mysql
    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
    quit

Node.js

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

Ghost-CLI

$ sudo npm install [email protected] -g

Ghost

During the Ghost installation, you will be asked the following questions:

Question Answer Notes
Enter your blog URL: http://www.musingitoutloud.com
Enter your MySQL hostname: localhost
Enter your MySQL username: root
Enter your MySQL password: [hidden] This is the password defined earlier in MySQL.
Enter your Ghost database name: musingitoutloud_prod
Sudo Password [hidden] Password for ghostadmin account
Do you wish to set up "ghost" mysql user? Yes
Do you wish to set up Nginx? Yes
Do you wish to set up SSL? Yes In this output below I selected No as I'm using an ADC & WAF for SSL Offload.
Do you wish to set up Systemd? Yes
Do you want to start Ghost? Yes
$ sudo mkdir /var/www/websitename
$ sudo chown ghostadmin:ghostadmin /var/www/musingitoutloud
$ cd /var/www/musingitoutloud
$ sudo su ghostadmin
$ ghost install
✔ Checking system Node.js version
✔ Checking logged in user
✔ Checking current folder permissions
✔ Checking operating system compatibility
✔ Checking for a MySQL installation
✔ Checking memory availability
✔ Checking for latest Ghost version
✔ Setting up install directory
✔ Downloading and installing Ghost v2.9.0
✔ Finishing install process
? Enter your blog URL: http://www.musingitoutloud.com
? Enter your MySQL hostname: localhost
? Enter your MySQL username: root
? Enter your MySQL password: [hidden]
? Enter your Ghost database name: musingitoutloud_prod
✔ Configuring Ghost
✔ Setting up instance
+ sudo useradd --system --user-group ghost
? Sudo Password [hidden]
+ sudo chown -R ghost:ghost /var/www/musingitoutloud/content
✔ Setting up "ghost" system user
? Do you wish to set up "ghost" mysql user? Yes
✔ Setting up "ghost" mysql user
? Do you wish to set up Nginx? Yes
✔ Creating nginx config file at /var/www/musingitoutloud/system/files/www.musingitoutloud.com.conf
+ sudo ln -sf /var/www/musingitoutloud/system/files/www.musingitoutloud.com.conf /etc/nginx/sites-available/www.musingitoutloud.com.conf
+ sudo ln -sf /etc/nginx/sites-available/www.musingitoutloud.com.conf /etc/nginx/sites-enabled/www.musingitoutloud.com.conf
+ sudo nginx -s reload
✔ Setting up Nginx
? Do you wish to set up SSL? No
ℹ Setting up SSL [skipped]
? Do you wish to set up Systemd? Yes
✔ Creating systemd service file at /var/www/musingitoutloud/system/files/ghost_www-musingitoutloud-com.service
+ sudo ln -sf /var/www/musingitoutloud/system/files/ghost_www-musingitoutloud-com.service /lib/systemd/system/ghost_www-musingitoutloud-com.service
+ sudo systemctl daemon-reload
✔ Setting up Systemd
? Do you want to start Ghost? Yes
+ sudo systemctl is-active ghost_www-musingitoutloud-com
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
+ sudo systemctl is-active ghost_www-musingitoutloud-com
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
+ sudo systemctl start ghost_www-musingitoutloud-com
✔ Starting Ghost
+ sudo systemctl is-enabled ghost_www-musingitoutloud-com
+ sudo systemctl enable ghost_www-musingitoutloud-com --quiet
✔ Enabling Ghost instance startup on server boot

Ghost uses direct mail by default. To set up an alternative email method read our docs at https://ghost.org/mail

------------------------------------------------------------------------------

Ghost was installed successfully! To complete setup of your publication, visit: 

    http://www.musingitoutloud.com/ghost/

Lets Encrypt

If you selected yes for configure SSL (highly recommended in most scenarios), you will need to provide an email address for the certificate registration. You will also need to renew the certificate every 3 months. Use the following command:

$ sudo /etc/letsencrypt/acme.sh --issue --home /etc/letsencrypt \
   --domain www.musingitoutloud.com \
   --webroot /var/www/musingitoutloud/system/nginx-root \
   --accountemail [email protected]

where accountemail is the address provided during installation. Lets Encrypt requires access to the server via the hostname the certificate is issued to over http.