Ghost
On this site, you find a guide to install and configure Ghost on CloudPanel.
Creating a Node.js Site
Via CloudPanel
- Click on + Add Site and then click on Create a Node.js Site.
- Enter the Domain Name, Node.js Version, and the App Port, and click on Create.
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
Create a Database and copy the Database Name, Database User Name, Database User Password.
Log in via SSH with the Site User:
ssh john-doe@server-ip-address
- Install the Ghost CLI:
npm install ghost-cli@latest -g
- 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/
- Enter your Blog Url like https://www.domain.com/
- Start Ghost by confirming with Y:
- The installation is done. Open your site in the browser and create an admin user.
Deployment
Ghost needs to be started after an instance reboot. We will create a script that gets executed after the reboot.
- Log in via SSH with the Site User:
ssh john-doe@server-ip-address
- Create scripts directory:
mkdir ~/scripts/
- 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 &
- Set execution permissions:
chmod 700 ~/scripts/ghost-start.sh
- Edit the crontab for the site user.
crontab -e
- Replace SITE_USER with your site user and add the following line:
@reboot /home/$SITE_USER/scripts/ghost-start.sh &> /dev/null
- Reboot and test if Ghost is running as expected.