Ghost Blog Hosting with Supervisord and Nginx on Ubuntu 14.04

Installing Prerequistes

sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install nodejs
sudo apt-get install nodejs-legacy
sudo apt-get install npm

Installing Ghost

sudo mkdir /home/sites
cd /home/sites
sudo wget
sudo unzip -d ghost
cd ghost
sudo npm install — production

Setting up Ghost

cd /home/sites/ghost
sudo cp config.example.js config.js

Site URL and mail settings are in the production section, The URL is necessary. Otherwise, the links will take you to the default page. Ghost can function without the mail settings, but this is recommended that you add them.

sudo nano config.js

Change the url and change the host in the server section to

var path = require(‘path’),
config = {
// ### Production
// When running Ghost in the wild, use the production environment
// Configure your URL and mail settings here
production: {
url: ‘',
mail: {
// Your mail settings
database: {
client: ‘sqlite3’,
connection: {
filename: path.join(__dirname, ‘/content/data/ghost.db’)
debug: false
server: {
// Host to be passed to node’s `net.Server#listen()`
host: ‘’,
// Port to be passed to node’s `net.Server#listen()`, for iisnode s$
port: ‘2368’

Starting Ghost

sudo npm start — production

You can now access your blog on following url.

Installing and configuring Nginx

sudo apt-get install nginx
cd /etc/nginx/sites-available/
sudo nano ghost

Add the following

server {
listen 80;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;

Create a symlink to activate the ghost server block

cd /etc/nginx/sites-enabled/

sudo ln -s ../sites-available/ghost ghost

Unlink the default block

sudo unlink default

Restart Nginx

sudo service nginx restart

Securing Ghost Directory

sudo adduser — shell /bin/bash — gecos ‘Ghost application’ ghost

Granting ownership

sudo chown -R ghost:ghost /home/sites/ghost/

Now Login into ghost user

su — ghost
cd /home/sites/ghost
npm start — production

Ctrl+D or exit to logout of ghost user

Installing and configuring Supervisord

sudo apt-get install supervisor
sudo service supervisor start

Configure Ghost :

sudo nano /etc/supervisor/conf.d/ghost.conf

environment = NODE_ENV=”production”
directory = /home/sites/ghost
command = node /home/sites/ghost/index.js
user = ghost
autostart = true
autorestart = true
startretries = 3
stdout_logfile = /var/log/supervisor/ghost-access.log
stdout_logfile_maxbytes = 1MB
stdout_logfile_backups = 10
stderr_logfile = /var/log/supervisor/ghost-error.log
stderr_logfile_maxbytes = 1MB
stderr_logfile_backups = 10

Starting Ghost using Supervisor

sudo supervisorctl start ghost