Ghost on Ubuntu

Aug 25, 2015
[Ghost]( is a free open source blogging platform built with [Node.js]( It started as a Kickstarter project and turned into a great blogging platform that is still under active development.

It can be self hosted or you can choose a hosted built at

It uses Sqlite by default as it’s Database, you use MySQL to.

Its easy to setup and maintain Ghost compared to other blogging platforms and CMS, self hosting gives you the freedom to choose your own server.

If you don’t already have a server or planning to host it on a Ubuntu VPS, I would personally recommend Digital Ocean, is also hosted on it.

Getting started

Installing dependencies required for running Ghost into production.

Installing Node.js

Adding the Node.js repository to get the latest stable version of Node.js (requires: cURL).

“` curl -sL | sudo bash – “`
Installing Node.js
“` sudo apt-get install nodejs # NPM comes with it. “`
Adding [NGINX]( stable repository to get latest version of NGINX.
“` sudo apt add-repository ppa:nginx/stable “`
Installing NGINX.
“` sudo apt-get update && sudo apt-get install nginx-full “`
Installing Sqlite.
“` sudo apt-get install sqlite3 “`
Installing Supervisor, for handling Ghost at startup and crash or restart.
“` sudo apt-get install supervisor “`
Downloading [Ghost stable]( zip.
“` wget “`
cURL users can get it to.
“` curl -# -L -O “`
Unzipping Ghost zip file that we downloaded.
“` unzip -d Ghost “`
Turn ``Ghost` directory into current directory.`
``` cd Ghost/ ```
Installing production dependencies for Ghost using NPM.
``` npm install --production ```
Test run to see, to see if everything is running fine:
``` npm start --production ```
If you don’t get any errors, you are good to go ahead.

Adding Ghost service configuration to Supervisor, by creating a new <code class="highlighter-rouge">ghost.conf file.

``` sudo nano /etc/supervisor/conf.d/ghost.conf ```
Add the lines below, edited it to match you system settings, you can it under a separate user for Ghost, **don’t run it under the root user**.
``` [program:ghost] command = npm start --production directory = /path/to/ghost # Change to the place you have stored Ghost user = ghost # Change the username Ghost will be running under autostart = true autorestart = true stdout_logfile = /var/log/supervisor/ghost.log stderr_logfile = /var/log/supervisor/ghost_err.log environment = NODE_ENV="production" ```
Save file CTRL + X + Y and hit ENTER.

Ghost stores all it’s configuration in a <code class="highlighter-rouge">config.js file, which need to be created by coping the <code class="highlighter-rouge">config.example.js file to <code class="highlighter-rouge">config.js.

``` cp config.example.js config.js ```
Edit the file to your preference, don’t forget to edit the ``url:` string to your domain.`

Starting Ghost as a Supervisor service.

``` sudo supervisorctl start ghost ```
Now Ghost will be running on port 2368.

Reverse proxying it using NGINX to run it on port 80.

Edit the <code class="highlighter-rouge">default nginx configuration.

``` sudo nano /etc/nginx/sites-enabled/default ```
Add the following to the ``default` file.`
``` server { listen 80; server_name; # Change this to your domain``` location / { proxy_pass; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; }


Restart NGINX.
``` sudo service nginx restart ```
Visit your domain, you will now be greeted by Ghost setup page, fill the required information, now you have Ghost setup.

Happy Blogging.

Thanks for reading, have a question? leave a comment below.

If you like this content, please consider buying me a coffee.

Buy me a coffeeBuy me a coffee

You will get access to contributer exclusive resources and content.

Thank you!

Darryl Dias

I am a student, artist, and author currently living in Florida. My interests range from technology to arts. I am also interested in programming, writing

Analytics by GoSquared