Prerequisites

Officially supported :

  • Ubuntu 16.04 or Ubuntu 18.04
  • 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 1 GB memory
  • A registered domain name

Before you start this installation if you want to configure the SSL certificate you should set an A record  from the domain you plan to use, pointing at the server’s IP address and ensure that it's resolving correctly.

Create User: (Don't use username 'ghost' as it conflicts Ghost-CLI)

# Login via SSH
ssh root@your_server_ip

# Create a new user and follow prompts
adduser <user>
Create User in Ubuntu
# Update package lists
sudo apt-get update

# Update installed packages
sudo apt-get upgrade
Update Packages in Ubuntu
# Install NGINX
sudo apt-get install nginx
Install Nginx in Ubuntu
sudo ufw allow 'Nginx Full'
Add Firewall rule in Ubuntu
# Install MySQL
sudo apt-get install mysql-server
Install mysql server in Ubuntu
# To set a password, run
sudo mysql

# Now update your user with this password
# Replace 'password' with your password, but keep the quote marks!
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

# Then exit MySQL
quit

# and login to your Ubuntu user again
su - <user>
Connect MySQL server database and Create user
# Add the NodeSource APT repository for Node 10
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash

# Install Node.js
sudo apt-get install -y nodejs
Install NodeJs in Ubuntu
sudo npm install ghost-cli@latest -g
Install Ghost-CLI in Ubuntu
# We'll name ours 'ghost' in this example; you can use whatever you want
sudo mkdir -p /var/www/ghost

# Replace <user> with the name of your user who will own this directory
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
Create directory and set owner and permissions in Ubuntu
ghost install
Install Ghost in Ubuntu

CLI will ask a number of questions to configure your site.

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.

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.

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?

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.

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.

Reference - https://ghost.org/docs/install/ubuntu/

Thank you!!