Creating a Ghost Blog on a CentOS 7 Server

Posted on

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 Vultr instance.

If you wish to create a Ghost blog on Ubuntu, please read 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.

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 && unzip
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: '',

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

Those will be the first lines of your configuration. Change 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 -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!

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article

Leave a Reply

Your email address will not be published. Required fields are marked *