Creating a Ghost Blog on a CentOS 7 Server

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.

wget -ivh epel-release-7-8.noarch.rpmyum 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 ghost-latest.zipnpm 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 blogchown blog:blog -R /var/wwwsu blogcd /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 Configurationvar path = require('path'),    config;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 pm2su blog -c echo "export NODE_ENV=production" >> ~/.profilesu blog -c source ~/.profilesu 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.rpmrpm -ivh /tmp/nginx.rpmrm /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;        proxy_pass;    }}' > /etc/nginx/conf.d/default.conf

Finally, start NGINX:

service nginx start

And Ghost:

cd /var/wwwpm2 startup centossu blog    pm2 start index.js --name ghostpm2 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

No comments

Powered by Blogger.