Install Ghost on Linode

Linode.com is a popular choice for a VPS hosting. This post will walk through how to install Ghost on Linode.

Install

Install Node

Setup with Ubuntu, then install with Ubuntu

1
2
3
4
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
node -v
npm -v

Install nginx

apt-get install nginx

Download and Install Ghost

1
2
3
4
5
6
7
mkdir -p /var/www/
cd /var/www/
wget -O ghost.zip https://ghost.org/zip/ghost-latest.zip
unzip -d ghost ghost.zip
cd ghost
npm install --production
cp config.example.js config.js

Deploy

Edit your config.js file. In the production section replace the following:

1
host: '127.0.0.1',

with

1
host: '[your Linode public IP]',

Create Ghost User, and start ghost

1
2
3
4
useradd ghost
chown -R ghost:ghost /var/www/ghost/
cd /var/www/ghost/
npm start --production

Keep Ghost Running

Ghost setup

Visiting http://your ip address:2368/ghost/ will show Welcome to your new Ghost blog.

There you have it, Node.js is installed, Ghost files are located in /var/www/ghost, and Ghost has been started. You can keep Ghost the way it is if you do not mind adding :2368 to the end of your url, but we would highly recommend you check out the following two articles to help get your Ghost blog fully ready:

With Nginx installed, we now need to tell Nginx that Ghost is ready for requests on port 2368. New Nginx configuration files can be added into /etc/nginx/conf.d/. We would recommend creating your configuration file in this directory and naming it something meaningful, like: your-domain-name.conf. Once you have created your new Nginx conf file place the following into your file, replacing your-domain-name.conf.com with your domain name:

1
2
3
cd /etc/nginx/conf.d/
ls
vim jianghao.wang.conf

add following to jianghao.wang.conf

1
2
3
4
5
6
7
8
9
server {
listen 80;
server_name **ip addess**;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2368;
}
}

If you find a sample Nginx configuration files found in /etc/nginx/conf.d/, I would recommend deleting them. Now restart Nginx to make your changes take affect:

1
2
rm 
sudo service nginx restart

Your Ghost blog is now reachable via your domain name, on port 80, through Nginx to port 2368.


Reference:

  1. How To Install Ghost On Linode