Simple Way Installing Ghost on Debian

This tutorial tested on Debian Squid and Wheezy. You can also using this tutorial on Ubuntu. No more words, just try and do it with your own risk.

1. Compile Node.JS

apt-get update  
apt-get clean  
apt-get install git-core curl build-essential openssl libssl-dev sqlite3 libsqlite3-dev

cd /usr/src; git clone https://github.com/joyent/node.git  
cd node; git checkout v0.10.21  
./configure --openssl-libpath=/usr/lib/ssl
make  
make install

node -v  
npm -v  

2. Installing Ghost

mkdir -p /home/aris/ghost  
cd /home/aris/ghost  
wget --no-check-certificate http://po.st/ghlts  
unzip ghost-*.zip; rm ghost-*.zip

npm install sqlite3 mysql  
npm install --production  

3. Using Ghost with custom domain

Copy config.example.js to config.js

Open config.js and edit the domain http://my-ghost-blog.com to your own domain.

4. Using Ghost behind nginx

apt-get install nginx

cat > /etc/nginx/sites-available/ospian-ghost <<EOF  
server {  
  listen 80;
  server_name ospian.com;
  rewrite ^/(.*) http://aris.ospian.com/$1 permanent;
}
server {  
  listen 80;
  server_name aris.ospian.com;
  access_log /home/aris/ghost/akses.log;
  error_log     /home/aris/ghost/error.log;
  location / {
    proxy_pass                    http://localhost:2368/;
    proxy_set_header     Host $host;
    proxy_buffering     off;
  }
}
EOF

ln -s /etc/nginx/sites-available/ospian-ghost /etc/nginx/sites-enabled/ospian-ghost  
service nginx restart  

Create the bash script for starting Ghost /home/aris/ghost/run.sh

#!/bin/sh
GHOST_DIR="/home/aris/ghost"  
cd $GHOST_DIR  
export NODE_ENV=production  
exec /usr/local/bin/npm start $_GHOST_DIR 2>&1 >> ghost_run.log  

Then set the permission:

chmod +x /home/aris/ghost/run.sh  

Run Ghost with execute run.sh

cd /home/aris/ghost  
./run.sh

To stop Ghost, firstly get running process

netstat -tunap | grep node  
kill <pid>  
/home/aris/ghost/run.sh

5. Autorun Ghost when server startup using crontab

crontab -e -u aris  

and then add this line:

@reboot /home/aris/ghost/run.sh > /home/aris/ghost/cron.log 2>&1

NB: don't forget to change the path /home/aris/ghost with your Ghost location and domain aris.ospian.com with your own domain.

Thank you for reading. Enjoy it an d enjoy your Ghost !!!