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 http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpmrpm -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 https://ghost.org/zip/ghost-latest.zip && 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: 'http://my-ghost-blog.com',

Also, find the line host: 127.0.0.1 and change it to host: 0.0.0.0.

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 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 http://nginx.org/packages/mainline/centos/7/x86_64/RPMS/nginx-1.11.0-1.el7.ngx.x86_64.rpm -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         http://127.0.0.1:2368;    }}' > /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

Conclusion

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.