[Ghost](https://ghost.org) is open source blogging platform written in [Node.js](https://nodejs.org) that offers self hosting and hosted service.

We are going to self host Ghost on a Raspberry Pi.

This guide will take you through the steps of setting up a self hosted Ghost production environment.

I am working on this setup with a clean install of Raspbian and headless setup, you can lean how to enable SSH from here.

You can SSH into your Raspberry Pi(Mac/Linux). If you are a Windows user you need to use Putty

“`
ssh pi@the-ip-address-of-the-pi
“`

The default username and password of the Raspbian install is.

user: pi

password: raspberry

Installing Node.js

Downloading Node.js(NPM ships with it)

“`
wget http://node-arm.herokuapp.com/node_latest_armhf.deb
“`

Installing Node.js(required by Ghost)

“`
sudo dpkg -i node_latest_armhf.deb
“`

Installing Sqlite required by Ghost.

“`
sudo apt-get install sqlite3
“`

Installing NGINX(used to reverse proxy Ghost)

“`
sudo apt-get install nginx-full
“`

Installing Supervisor(to manage Ghost)

“`
sudo apt-get install supervisor
“`

#### Ghost setup

This will download the latest version of Ghost.

“`
wget https://ghost.org/zip/ghost-latest.zip
“`

Unzipping the folder we just downloaded.

“`
unzip ghost-latest.zip -d Ghost
“`

Set “Ghost/` as the current directory`

“`
cd Ghost/
“`

Installing dependencies used by Ghost using “NPM`.`

“`
npm install –production
“`

Run the command below to see everything works fine.

“`
npm start –production
“`

Time to setup turn Ghost into a service.

Creating the <code class="highlighter-rouge">ghost.conf file for Supervisor to manage Ghost.

“`
touch /etc/supervisor/conf.d/ghost.conf
“`

Editing the file, you can choose any editor you like.

“`
nano /etc/supervisor/conf.d/ghost.conf
“`

Add these lines to the “ghost.conf` file.`

“`
[program:ghost]
command = npm start –production
directory = /home/pi/Ghost/
user = pi
autostart = true
autorestart = true
stdout_logfile = /var/log/supervisor/ghost.log
stderr_logfile = /var/log/supervisor/ghost_err.log
environment = NODE_ENV=”production”
“`

Now save the file, in nano CTRL + X + Y.

You can start Supervisor, if it did not start after installing.

“`
service supervisord start
“`

Now set Supervisor to run on startup.

“`
sudo update-rc.d supervisord defaults
“`

Starting Ghost service we just created.

“`
sudo supervisord start ghost
“`

Ghost will be running in production in port 2368.

Reverse proxying Ghost with NGINX.

Editing the <code class="highlighter-rouge">default file.

“`
nano /etc/nginx/sites-enabled/default
“`

Add these lines

“`
server {
listen 80;
server_name yourdomain.com; # Change this to your hostname“`
location / {
proxy_pass http://127.0.0.1:2368;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}

 

}


Save the file

Now restart NGINX.

“`
service nginx restart
“`

Now visit your Raspberry Pi ip address. You will be presented with a beautiful setup screen.

You can edit the Ghost hostname and other settings by editing the <code class="highlighter-rouge">config.js stored in the Ghost folder.

Services like DynDNS can be used to manage hostname, if you want your Ghost blog to be public and use a domain name instead of the ip address.

If you have any questions or problem, leave a comment below.

I compiled a list of software and services that I use to improve my workflow, here is the link to the list.

Darryl Dias

I’m Darryl. I’m a 3D Artist, Programmer and Linux enthusiast. On this site I share my insights, tips and tricks, tutorials, methods and best practices.