We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – Install and Configure Ghost CMS on CentOS 8 / RHEL 8

Learn how to – Install and Configure Ghost CMS on CentOS 8 / RHEL 8.

This guide will detail the steps used to Install Ghost CMS on CentOS 8 / RHEL 8 Linux server. Ghost is an open source content management system designed for both beginners and professional bloggers and documentation teams alike. Ghost CMS has full support for Markdown and provides an easy to use web interface for both management and content generation.

For Ubuntu, check How to install Ghost CMS on Ubuntu

In this article, we will do installation of Ghost on CentOS 8 with Nginx as reverse proxy. I’m doing this setup on a fresh installation of CentOS 8. This is recommended to ensure you don’t break your Production environments.

Install Ghost on CentOS / RHEL 8

Here are the steps you’ll generally follow to install Ghost on RHEL / CentOS 8. Take a cup of coffee as you perform installation of Ghost on CentOS 8 / RHEL 8.

Step 1: Update CentOS system

We always begin our installation with yum package updates.

sudo dnf -y update
sudo reboot

After reboot, set your SELinux in permissive mode.

sudo setenforce 0
sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config

Step 2: Add EPEL repository

Some dependency packages will be pulled from EPEL repository. Add it to your system through command execution below.

sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

Step 3: Install MySQL / MariaDB database server

Install a database server for Ghost CMS. This can either be MySQL or MariaDB database server. We have the guides for setting MySQL or MariaDB database server.

When done, Create the database for ghost blog you plan to add:

$ mysql -u root -p
CREATE USER ghost@localhost IDENTIFIED BY "StrongPassword";
CREATE DATABASE  ghost; 
GRANT ALL ON ghost.* TO ghost@localhost;
FLUSH PRIVILEGES;
QUIT

Step 4: Install Node.js and PM2

The core of Ghost is written in Node.js. The npm package manager will be installed as a dependency.

sudo dnf remove -y @nodejs
curl --silent --location https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo dnf install -y nodejs

Confirm Node version

$ node -v
v16.15.0

The Ghost process can be controlled via pm2 process manager. Let’s ensure pm2 is installed in the system.

sudo npm install pm2 -g

Successful installation output;

Step 5: Install Ghost-CLI

Create Ghost admin user:

sudo useradd ghostadmin
sudo passwd ghostadmin
sudo usermod -aG wheel ghostadmin

We now need to install the package ghost-cli which provides ghost command.

$ sudo npm i -g ghost-cli
/usr/bin/ghost -> /usr/lib/node_modules/ghost-cli/bin/ghost
+ ghost-cli@1.21.0
added 478 packages from 270 contributors in 24.515s

$ which ghost
/usr/local/bin/ghost

Step 6: Configure Ghost on CentOS / RHEL 8

Create a new folder for Ghost Data:

Please note that:

  • Installing Ghost in the /root folder won’t work and result in a broken setup!
  • Installing Ghost in your /home/{user} folder won’t work and result in a broken setup!
  • Please only use /var/www/{folder} because it has the right permissions.

So let’s create this directory:

sudo mkdir -p /var/www/ghost
sudo chown ghostadmin:ghostadmin /var/www/ghost
sudo chmod 775 /var/www/ghost

Create your Ghost project (blog) folder:

sudo su - ghostadmin
cd /var/www/ghost
mkdir blog.example.com
cd blog.example.com

Where:

  • blog.example.com is the directory containing site/blog files.
  • /var/www/ghost is the path to your blogs directories

If you want install Ghost with database, run:

## Ghost with Sqlite db ###
ghost install --db=sqlite3

## Ghost with MySQL db ###
ghost install --db=mysql

For Development environment, you can do:

ghost install local

Provide service URL, database connection details, and agree to configure Systemd.

✔ Finishing install process
? Enter your blog URL: http://localhost:2368
? Enter your MySQL hostname: localhost
? Enter your MySQL username: ghost
? Enter your MySQL password: [hidden]
? Enter your Ghost database name: ghost
? Do you wish to set up Systemd? Yes

Finish the installation then confirm service status by running:

$ ghost ls
$ systemctl status ghost_blog-learnhowto-com
● ghost_blog-learnhowto-com.service - Ghost systemd service for blog: blog-learnhowto-com
   Loaded: loaded (/var/www/ghost/blog.ownyourlife.com.ng/system/files/ghost_blog-learnhowto-com.service; indirect; vendor preset: disab>
   Active: active (running) since Sat 2019-10-05 19:05:48 EAT; 10min ago
     Docs: https://docs.ghost.org
 Main PID: 12669 (ghost run)
    Tasks: 18 (limit: 11512)
   Memory: 142.9M
   CGroup: /system.slice/ghost_blog-learnhowto-com.service
           ├─12669 ghost run
           └─12678 /usr/bin/node current/index.js
...............................................................

Example:

Step 7: Configure Nginx proxy for Ghost CMS

Install Nginx

sudo dnf install @nginx

Create Nginx configuration file for Ghost.

sudo vi /etc/nginx/conf.d/ghost.conf

Add your Website configurations.

server {
    listen 80;
    listen [::]:80;

    server_name blog.example.com;
    root /var/www/ghost/blog.example.com/system/nginx-root;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:2368;
        
    }

    location ~ /.well-known {
        allow all;
    }

    client_max_body_size 50m;
}

Replace:

  • blog.example.com with your Ghost site URL
  • /var/www/ghost/blog.example.com with Path to your site DocumentRoot
  • http://127.0.0.1:2368 with local Ghost listening URL

Your Nginx configuration should not contain any error.

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Confirm the Node service backend is active.

$ sudo netstat -tunlp | grep 2368
tcp        0      0 127.0.0.1:2368          0.0.0.0:*               LISTEN      12678/node 

After confirmation, restart nginx service.

sudo systemctl enable --now nginx
sudo systemctl restart nginx

A successful restart is expected as a result of the executed command.

$ systemctl status nginx
 nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2019-10-06 12:05:47 EAT; 29s ago
  Process: 21817 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 21814 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 21812 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 21819 (nginx)
    Tasks: 2 (limit: 11512)
   Memory: 3.9M
   CGroup: /system.slice/nginx.service
           ├─21819 nginx: master process /usr/sbin/nginx
           └─21820 nginx: worker process

Oct 06 12:05:47 centos8.novalocal systemd[1]: Stopped The nginx HTTP and reverse proxy server.
Oct 06 12:05:47 centos8.novalocal systemd[1]: Starting The nginx HTTP and reverse proxy server...
Oct 06 12:05:47 centos8.novalocal nginx[21814]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Oct 06 12:05:47 centos8.novalocal nginx[21814]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Oct 06 12:05:47 centos8.novalocal systemd[1]: Started The nginx HTTP and reverse proxy server.

Open http and https service ports in the firewall.

sudo firewall-cmd --add-service={http,https} --permanent
sudo firewall-cmd --reload

Step 8: Access Ghost CMS Dashboard on CentOS 8 / RHEL 8

Your setup is now ready, access Ghost web admin interface where you can upload themes, change settings and write content using markdown syntax.

To complete setup of your publication, visit: http://blog.example.com/ghost.

Create your first Ghost administrator/publisher account by clicking on “Create your account”.

Optionally invite other members. You’ll get to Ghost CMS dashboard in a few.

Step 9: Ghost Basic Management Commands

Here are the commands you’ll need for most Ghost management operations.

Logs dir: /content/logs/
$ ghost start: Start ghost
$ ghost restart: Restart ghost
$ ghost run: Test if the ghost can start successfully
$ ghost uninstall: Re-install ghost
$ ghost update: Upgrade ghost
$ ghost update –force: Force upgrade if there are errors
$ ghost update –rollback: Revert to the earlier version if an upgrade fails
$ sudo npm i -g ghost-cli@latest: Upgrade Ghost-CLI
$ ghost ssl-renew: Renew ssl certificate
$ ls ./system/files/*.conf: System configuration files
$ ghost setup nginx: Manually Setup nginx
$ ghost setup nginx ssl: Setup nginx with SSL

Other CentOS / RHEL 8 installation guides:

Cart

Your Cart is Empty

Back To Shop