Official Power Up Hosting Blog

Everything about Linux, Windows, and hosting ;)

Nilesh Shinde
Author

If you want something you never had....You have to do something you've never done

Share


Our Newsletter


Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Tags


Twitter


Official Power Up Hosting Blog

Learn How to Install Ghost Blogging CMS on CentOS 6 & 7 (Nginx Enabled)

Nilesh ShindeNilesh Shinde

Looking to install Ghost on CentOS and Nginx?

Ghost is the publishing platform to the contestant.

Its founders John O'Nolan and Hannah Wolfe both of them coded this in Node.js.

Ghost can be the best platform to publish and for writers to write a blog. It is free to download and use.

Also..Ghost is a platform for nontechnical people too- so that's why Ghost provide simple options to run your Ghost blog.

It is overall customizable and easily open source blogging proclamation exists only mutually one end posting.

..and in this guide, we will learn how to Install Ghost from Scrach on CentOS 6 or 7 with Nginx Web Server.

how to install ghost on CentOS

Pre-requisites

  • CentOS 6/7 installed on your computer/server:
  • SSH access (Command line access to the server):
  • Root permissions
  • Node.js installed on the server
  • Nginx is installed on the server

What is Node.js?

Node.js is a Javascript programming platform which allows users to build fast, scalable and efficient web applications very easily.

[Node.js](https://nodejs.org/en/" target="_blank) is used to build applications and libraries using JavaScript by developers

..so the back-end of [javascript](https://en.wikipedia.org/wiki/JavaScript" target="_blank) executes code very fastly.

JavaScript is used on the both side client as well as server end..

..so developers requires JavaScript.

What is NginX?

Nginx and Apache HTTP server are the most popular web server. But Nginx is having high performance, flexible and lightweight program than the Apache HTTP Server.

Nginx is specially developed for C10K problem.

[C10K problem](https://en.wikipedia.org/wiki/C10k_problem" target="_blank) is the inability of a server to scale beyond 10,000 connections or clients..

..due to resource exhaustion.

Now:

We will start installation of ghost from scratch,

..using CentOS and Nginx

But, before we start the installation process..

..we need to ensure all packages are up to date.

Run:

#yum update -y

..and

#yum install -y wget

How to Install Node.js on CentOS

First:

Browse to the temp directory:

#cd /tmp

..and download the latest node.js zip file using the following command:

#wget http://nodejs.org/dist/v0.12.3/node-v0.12.3-linux-x64.tar.gz

Now:

Extract the downloaded file and run into the /usr directory using the following command:

 #cd /usr && tar --strip-components 1 -xzf /tmp/node-v0.12.3-linux-x64.tar.gz

Once done, now:

Add EPEL Repository for Nginx

..but before installing Nginx..

..we need to add EPEL repository, in order to do that..

Open the terminal and use following command:

sudo yum install epel-release

Now:

The Nginx repository is installed on your server.

How to Install Nginx On CentOS:

First:

Run the command below in sudo

sudo yum install nginx

That's it!

I have successfully installed Nginx on our server.

..and you can confirm it by directing your browser to your IP address.

how to install nginx on centos

On the page, you will see the message

Welcome to nginx on EPEL!

If you aren't sure about your server IP address

..then you can find out using the following command:

ifconfig eth0 | grep inet | awk '{ print $2 }'

How to Install Ghost on Nginx and CentOS

If you have followed the tutorial so far, you would have successfully deployed your Ngnix server..

Now:

I will show you How to Install & Configure Ghost to work with Nginx

First:

Create a new virtual host file inside Your newly deployed Nginx folder:

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

Inside the virtual host file write down below code:

server {
listen 0.0.0.0:80;
server_name yourdomain.com;
access_log /var/log/nginx/yourdomain.log;

location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header HOST $http_host;
    proxy_set_header X-NginX-Proxy true;

    proxy_pass http://127.0.0.1:2368;
    proxy_redirect off;
}
}

P.S. Replace yourdomain.com with your actual domain name

Now:

You have to enable the virtual host..

..to do so-use the following command:

sudo ln -s /etc/nginx/sites-available/ghost.conf /etc/nginx/sites-enabled

How to Start Nginx

Nginx does not run by default..

..and we need to start Nginx manually.

to do so, run the following command:

sudo /etc/init.d/nginx start

In case if you recieve the following error; while trying to run nginx…

[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)

That means..

Your Port 80 is already in use by another process and you'll be required to kill the active process..

You can use the following command to kill any active process on Port 80..

sudo fuser -k 80/tcp

How to Install GHOST CMS

In order to make the installation process refined and simple..

..I've introduced a 12 Step Process to Install Ghost blog platform

Step 1:

Login to your server as root OR any user with root permissions.

Step 2:

Check your node version and npm installation :

#node -v
#npm -v

Step 3:

You'll need to make a directory to put Ghost file.

I am using /var/www a common web directory on Linux:

#mkdir -p /var/www/

Step 4:

Head over to the directory:

#cd /var/www

Step5 :

Download the latest ghost package version.

#curl -L https://ghost.org/zip/ghost-latest.zip -o ghost.zip

Step 6:

Now:

You have downloaded the latest version of ghost.zip file.

It's time to extract the package first.

#unzip -uo ghost.zip -d ghost

Step 7:

Once all the above process is completed, the ghost files are located in the folder below:

#cd ghost

Step 8:

Finally, fire the command to install Ghost on your server:

#npm install --production

Step 9:

Now you can start Ghost to run on your server

#npm start

Step 10:

Now:

Shutdown Ghost by pressing the Control+C on your keyboard.

Step 11:

Now:

edit config.js file using vi editor or NANO

I'm going to use NANO over here..

#nano config.js

Note: If you don't have Nano editor you can install using below command:

#yum install nano -y

Step12:

Now in Nano OR vi editor, you need to change some lines under

  • Replace default URL to your own blog’s URL.
  • Change 127.0.0.1 IP address to your server’s IP address.
  • Change port 2368 to 80.

Save the changes

Step 13:

Now you'll have to start the ghost again using the magic command.

#npm start --production

install ghost
Congratulation !!

There you go!

Ghost has been successfully installed on your Nginx enabled CentOS server 6..

Special Note: The same guide can be followed if you are running CentOS 7

Conclusion

Ghost is an amazing blogging engine, and we at [Power Up Hosting](https://poweruphosting" target="_blank) are using it on an everyday basis.

If you are still stuck on WordPress then you should look into the [ghost vs wordpress](https://uditgoenka.com/blog/ghost-vs-wordpress/" target="_blank) guide and consider switching to Ghost.

Please share our article on your preferred social media and if you need any help then leave a comment below and I'll be happy to assist you..

Also, if you have any other tutorial/guide request then leave your request in the comment :)

Nilesh Shinde
Author

Nilesh Shinde

If you want something you never had....You have to do something you've never done

Comments