In this blog post we will show you how to install Ghost on an Ubuntu 14.04 VPS with the latest version of Nginx. Ghost is a new exciting blogging platform built on Node.js. The Ghost user interface is very simple and straightforward making it great for beginners as well as advanced users.This guide should work on other Linux VPS systems as well but was tested and written for Ubuntu 14.04 VPS.
Log in to your VPS via SSH
ssh myUsername@myVPS_IP
Update the system and install necessary packages.
root@vps:~# sudo apt-get update && sudo apt-get -y upgrade root@vps:~# sudo apt-get install python-software-properties unzip wget
Install Node.js
We will install the latest nodejs package from Chris Lea’s repo
root@vps:~# sudo add-apt-repository ppa:chris-lea/node.js root@vps:~# sudo apt-get update root@vps:~# sudo apt-get install nodejs
Download and extract the latest Ghost version
root@vps:~# mkdir ~/myGhostBlog root@vps:~# wget https://ghost.org/zip/ghost-latest.zip root@vps:~# unzip -d ~/myGhostBlog ghost-latest.zip root@vps:~# rm -f ghost-latest.zip
Install and Configure Ghost
Change into the ~/myGhostBlog directory and install Ghost.
root@vps:~# cd ~/myGhostBlog root@vps:~# npm install --production
When the installation is finished, run the following to start Ghost in development mode:
root@vps:~# npm start
If you see the below message, it means you’ve successfully installed Ghost.
Ghost is running in development... Listening on 127.0.0.1:2368 Url configured as: http://my-ghost-blog.com
Stop the process with Control-C
and continue with the Nginx installation.
Install and Configure Nginx
The latest version of Nginx 1.6.2 is not available via the default Ubuntu repositories, so we will add the “nginx/stable” PPA, update the system and install the nginx package.
root@vps:~# sudo add-apt-repository ppa:nginx/stable root@vps:~# sudo apt-get update root@vps:~# sudo apt-get install nginx
Create a new Nginx server block with the following content
root@vps:~#sudo nano /etc/nginx/conf.d/myWebsite.com
server { server_name myWebsite.com; listen 80; access_log /var/log/nginx/myGhostBlog-access.log; error_log /var/log/nginx/myGhostBlog-error.log; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_pass http://127.0.0.1:2368; } }
Test the Nginx configuration and restart the server
root@vps:~# sudo nginx -t root@vps:~# sudo /etc/init.d/nginx restart
Create an Upstart script
sudo nano /etc/init/ghost.conf
start on runlevel [2345] stop on shutdown respawn respawn limit 5 60 env name=ghost env uid=myUsername env gid=myUsername env daemon=/usr/bin/node env path=/home/myUsername/ghost/index.js export NODE_ENV=production script exec start-stop-daemon --start --make-pidfile --pidfile /var/run/$name.pid --name $name -c $uid:$gid -x $daemon $path >> /var/log/upstart/$name.log 2>&1 end script
You can now start, stop and restart your Ghost instance with
service ghost stop service ghost start service ghost restart
That’s it. Now open your browser, type the address of your website, e.g. http://myWebsite.com/ghost
and create an admin user to log in to the Ghost.
For more information about how manage your Ghost blog, please refer to the Ghost website.
Of course you don’t have to do any of this if you use one of our Fully-Managed Ubuntu Hosting services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.