Skip to main content

Ghost

On this site, you find a guide to install and configure Ghost on CloudPanel.

Creating a Node.js Site

Via CloudPanel

  1. Click on + Add Site and then click on Create a Node.js Site.
Add Node.js Site
  1. Enter the Domain Name, Node.js Version, and the App Port, and click on Create.
Add Ghost Site Form

Via CloudPanel CLI

You can create a Node.js Site with the following command as root user if you like the command line.

clpctl site:add:nodejs --domainName=www.domain.com --nodejsVersion=18 --appPort=2368 --siteUser='john-doe' --siteUserPassword='!secretPassword!'

Creating a Ghost project

  1. Create a Database and copy the Database Name, Database User Name, Database User Password.

  2. Log in via SSH with the Site User:

ssh john-doe@server-ip-address
  1. Install the Ghost CLI:
npm install ghost-cli@latest -g
  1. Replace DATABASE_USERNAME, DATABASE_USER_PASSWORD, DATABASE_NAME, SITE_USER, and DOMAIN and install Ghost.
ghost install --db mysql --port 2368 \
--dbhost 127.0.0.1 \
--dbuser $DATABASE_USER_NAME \
--dbpass $DATABASE_USER_PASSWORD \
--dbname $DATABASE_NAME \
--process local \
--no-setup-linux-user \
--no-setup-ssl \
--no-setup-nginx \
--dir /home/$SITE_USER/htdocs/$DOMAIN/
  1. Enter your Blog Url like https://www.domain.com/
Ghost - Enter Blog Url
  1. Start Ghost by confirming with Y:
Start Ghost Dialog
  1. The installation is done. Open your site in the browser and create an admin user.
Welcome to Ghost

Deployment

Ghost needs to be started after an instance reboot. We will create a script that gets executed after the reboot.

  1. Log in via SSH with the Site User:
ssh john-doe@server-ip-address
  1. Create scripts directory:
mkdir ~/scripts/ 
  1. Create a start script:
nano ~/scripts/ghost-start.sh

Modify the --dir value and save the start script:

#!/bin/bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
ghost start --dir $HOME/htdocs/ghost.moby.io/ --no-setup-linux-user > $HOME/logs/ghost.log &
  1. Set execution permissions:
chmod 700 ~/scripts/ghost-start.sh
  1. Edit the crontab for the site user.
crontab -e
  1. Replace SITE_USER with your site user and add the following line:
@reboot /home/$SITE_USER/scripts/ghost-start.sh &> /dev/null
  1. Reboot and test if Ghost is running as expected.