Learn Creating a Ghost Blog on a CentOS 7 Server

August 27, 2019

Table of Contents

In this article, we will be creating a Ghost blog on a CentOS 7 installation. Ghost is a free, open source blogging platform written in Javascript and NodeJS.

Ghost runs excellent on any sized IT Web Services instance.

https://www.itweb.services/tutorials/linux-guides/run-ghost-with-nginx-as-reverse-proxy-on-ubuntu-14-04-lts”>this article instead.

Step 1: Installing dependencies

Because the software was written in NodeJS, we’ll need to install the epel-release package in order to access the required repository to install NodeJS.

wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
rpm -ivh epel-release-7-8.noarch.rpm
yum install npm nodejs unzip zip screen -y

Now, let’s create a directory for our Ghost blog.

mkdir -p /var/www/
cd /var/www/
wget https://ghost.org/zip/ghost-latest.zip && unzip ghost-latest.zip
npm install --production

Great job. Now, let’s configure it.

Step 2: Configuring Ghost

First off, we’ll need another user to isolate privileges.
Create one by executing:

useradd blog
chown blog:blog -R /var/www
su blog
cd /var/www/
cp config.example.js config.js

Before we actually start the blogging software, we need to make a few changes.

nano config.js
// # Ghost Configuration
var path = require('path'),
config = {
    // ### Production
    // When running Ghost in the wild, use the production environment.
    // Configure your URL and mail settings here
    production: {
        url: 'http://my-ghost-blog.com',

Also, find the line host: and change it to host:

Those will be the first lines of your configuration. Change http://my-ghost-blog.com to your blog’s URL.
Do not change the host, as it is critical that only local users can see it.

Last thing for this step is to install PM2, a NodeJS process manager.
Execute the following commands:

npm install -g pm2
su blog -c echo "export NODE_ENV=production" >> ~/.profile
su blog -c source ~/.profile
su blog -c pm2 kill

Step 3: Configuring the NGINX proxy

This is important if you want users to be able to see your blog.
Run the following commands as the root user once more:

wget http://nginx.org/packages/mainline/centos/7/x86_64/RPMS/nginx-1.11.0-1.el7.ngx.x86_64.rpm -O /tmp/nginx.rpm
rpm -ivh /tmp/nginx.rpm
rm /etc/nginx/conf.d/default.conf

Populate the default.conf file:

echo 'server {
    listen 80;
    server_name _;
    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
}' > /etc/nginx/conf.d/default.conf

Finally, start NGINX:

service nginx start

And Ghost:

cd /var/www
pm2 startup centos
su blog    
pm2 start index.js --name ghost
pm2 dump


In this article, you learned how to create your own Ghost blog and proxy it to the public.
Happy blogging!

Need help?

Do you need help setting up this on your own service?
Please contact us and we’ll provide you the best possible quote!