We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

How to Install Ghost CMS on Ubuntu 18.04 – Google Cloud

How to Install Ghost CMS on Ubuntu 18.04 with Google Cloud and connect with Cloud SQL for database.

Ghost is an open-source powerful blog platform built over Node.js and it’s also fully customizable.

This setup is tested on Google Cloud Platform, so this guide can be used on any other cloud hosting services or VPS or Dedicated server running Ubuntu.

Prerequisites

  1. Your Compute Engine Instance running with minimum 1 GB RAM.
  2. For setting up Compute Engine, see the Setting up Compute Engine Instance.
  3. Domain name is pointed to your virtual machine.
  4. For setting up Cloud DNS, see the Setting up Google Cloud DNS for your domain.
  5. Google Cloud SQL Setup, see Setup Cloud SQL and connect with Compute Engine.

Install Nginx

Ghost uses Nginx web server, you can start updating the packages and install Nginx. SSH to your VM Instance and execute the following commands

sudo apt update
sudo apt upgrade

sudo apt install nginx

Once Nginx is installed proceed to configure and enable UFW.

sudo ufw allow OpenSSH
sudo ufw allow 'Nginx HTTP'
sudo ufw allow 'Nginx HTTPS'
sudo ufw enable

Install Node.js

To install Ghost you need a supported Node.js version, so you can use the officially recommended Node.js v10.

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

Confirm the Node.js and NPM installation with the following commands.

node -v
npm -v

You will get the installed version number.

Install Ghost-CLI

You can use the official ghost-cli to setup MySQL user and database and configure Nginx as reverse proxy and finally secure the site with Let’s Encrypt SSL certificate.

sudo npm install [email protected] -g

Install Ghost

Once your server is setup and ghost-cli is installed you can install Ghost.

Note: Installing Ghost in /root or home/ directories results in a broken setup. Use a custom directory with properly configured permissions.

You can use the recommended location to install Ghost which is /var/www/ghost

sudo mkdir /var/www/ghost

Set up correct permissions.

sudo chown $USER:$USER /var/www/ghost
sudo chmod 775 /var/www/ghost

Move inside the directory and install Ghost.

cd /var/www/ghost/
ghost install

You will see the output as follows.

Output
✔ Checking system Node.js version
✔ Checking logged in user
✔ Checking current folder permissions
✔ Checking operating system compatibility
Local MySQL install not found. You can ignore this if you are using a remote MySQL host.
Alternatively you could:
a) install MySQL locally
b) run ghost install --db=sqlite3 to use sqlite
c) run ghost install local to get a development install using sqlite3.
? Continue anyway? (y/N)

Type Y and hit Enter

Output
MySQL check skipped
ℹ Checking for a MySQL installation [skipped]
✔ Checking memory availability
✔ Checking for latest Ghost version
✔ Setting up install directory
✔ Downloading and installing Ghost v2.13.1
✔ Finishing install process

Now you will be prompted to enter your blog URL, enter http://yourdomainname.com

MySQL hostname enter Cloud SQL IP Address

MySQL username enter username

MySQL password enter password

Ghost database name enter database name

Output
? Enter your blog URL: http://yourdomainname.com
? Enter your MySQL hostname: CLOUD_SQL_IP_ADDRESS
? Enter your MySQL username: username
? Enter your MySQL password: password
? Enter your Ghost database name: database_name
✔ Configuring Ghost
✔ Setting up instance
sudo useradd --system --user-group ghost
sudo chown -R ghost:ghost /var/www/ghost/content
✔ Setting up "ghost" system user
? Do you wish to set up "ghost" mysql user? Yes

You will be asked to setup ghost user, you need to allow this setup.

Output
MySQL user is not "root", skipping additional user setup
ℹ Setting up "ghost" mysql user [skipped]
? Do you wish to set up Nginx? Yes

Allow Nginx setup.

Output
✔ Creating nginx config file at /var/www/ghost/system/files/yourdomainname.com.conf
sudo ln -sf /var/www/ghost/system/files/yourdomainname.com.conf /etc/nginx/sites-available/yourdomainname.com.com.conf
sudo ln -sf /etc/nginx/sites-available/yourdomainname.com.com.conf /etc/nginx/sites-enabled/yourdomainname.com.conf
sudo nginx -s reload
✔ Setting up Nginx
? Do you wish to set up SSL? Yes

Allow SSL setup and provide your email address to create and install Let’s Encrypt certificate.

Output
? Enter your email (For SSL Certificate) your_email_address
sudo mkdir -p /etc/letsencrypt
sudo ./acme.sh --install --home /etc/letsencrypt
sudo /etc/letsencrypt/acme.sh --issue --home /etc/letsencrypt --domain yourdomainname.com.com --webroot /var/www/ghost/system/nginx-root --reloadcmd "nginx -s reload" --accountemail your_email_address
sudo openssl dhparam -out /etc/nginx/snippets/dhparam.pem 2048
sudo mv /tmp/ssl-params.conf /etc/nginx/snippets/ssl-params.conf
✔ Creating ssl config file at /var/www/ghost/system/files/yourdomainname.com-ssl.conf
sudo ln -sf /var/www/ghost/system/files/yourdomainname.com-ssl.conf /etc/nginx/sites-available/yourdomainname.com-ssl.conf
sudo ln -sf /etc/nginx/sites-available/yourdomainname.com-ssl.conf /etc/nginx/sites-enabled/yourdomainname.com-ssl.conf
sudo nginx -s reload
✔ Setting up SSL
? Do you wish to set up Systemd? (Y/n)

You will be prompted to set up a systemd service. Press Y to continue.

Output
✔ Creating systemd service file at /var/www/ghost/system/files/ghost_yourdomainame-com.service
sudo ln -sf /var/www/ghost/system/files/ghost_yourdomainname-com.service /lib/systemd/system/ghost_yourdomainname-com.service
sudo systemctl daemon-reload
✔ Setting up Systemd
? Do you want to start Ghost? (Y/n)

Now press Y to start Ghost.

Ghost is installed successfully and you can access the admin interface by http://yourdomainname.com/ghost

You will be greeted with the Ghost Welcome page.

41b11edc ghost welcome page

Click Create your account.

824acf24 ghost create account

Fill all the details and complete the setup and visit the dashboard.

ca5aba4b ghost dashboard

That’s all, Great! In this tutorial, you installed Ghost, configured Nginx to proxy requests to Ghost, and ensured that Ghost runs as a system service.

Cart

Your Cart is Empty

Back To Shop