Install & Host Ghost with Nginx on Ubuntu

Ghost is an Open Source application which allows us to write and publish our own blog, giving you the tools to make it easy and even fun to do. It’s simple, elegant, and designed so that we can spend less time making our blog work and more time blogging.

Before we start installing it on our VPS, we should make sure that we meet all requirements. We need to have our Ubuntu server operating properly, we need to point our domain to it and we have to obtain a copy of Ghost.
# sudo apt-get update
In order to install npm, we should execute the following command. These will install npm and all its prerequisites.
# sudo apt-get install python-software-properties python g++ make
# sudo add-apt-repository ppa:chris-lea/node.js
# sudo apt-get update
# sudo apt-get install nodejs
Now we should have npm installed. If we simply try to execute nom command, we should get its help information in the console. We are ready to install Ghost now.
# cd ~
# wget
# unzip
# cd ghost-0.4.2
# npm install --production
The next step is to install nginx. Nginx installation is pretty easy and straight forward:
# sudo apt-get install nginx
That’s it, nginx is installed. Now we need to configure it. First, we change to nginx directory and remove the default configuration file and create a new one:
# cd /etc/nginx/
# rm sites-enabled/default
# cd sites-available
# touch ghost
Then, we need to open /etc/nginx/sites-available/ghost in our favorite editor, and the paste the following content inside:
server {
    server_name ****;
    access_log /var/log/nginx/ghost.log;

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

        proxy_redirect off;
Next, we need to create a symbolic link to activate the configuration.
# ln -s /etc/nginx/sites-available/ghost /etc/nginx/sites-enabled/ghost
If we restart nginx and start ghost again, we should get Ghost welcome page in our browser. If that is the case, we are done with the installation. The last thing we need to do is to make us able to start/stop the Ghost service like any other server on Ubuntu, using service start and service stop commands. In order to do that we need to create new file in /etc/init directory.
# cd /etc/init
# edit ghost.conf
and paste the following content in it:
# ghost

# description "An Upstart task to make sure that my Ghost server is always running"
# author "Your Name Here"

start on startup

    cd /root/ghost
    npm start
end script
service ghost stop 
service ghost start 
service ghost restart 
That concludes the configuration. Now we have fully functional ghost server that will start automatically when system boots up. We can enjoy our blogging on a beautifully designed platform dedicated to that.

About Author:

I am a Linux Administrator and Security Expert with this site i can help lot's of people about linux knowladge and as per security expert i also intersted about hacking related news.TwitterFacebook

Newer Post
Older Post


Post a Comment