Menu

Installing Ghost on a LAMP Debian Wheezy

I saw a Ghost!

Ghost is a blog engine I discovered a few days ago. It’s light, fast and very easy to configure and maintain. It’s totally content oriented and everything is done for a good readability on a phone, tablet or desktop computer.

In my opinion, it’s everything you could ask for in a blog.

Technically Ghost is based on NodeJS which means it’s incredibly fast. Forget all the heavy blog solutions like WordPress. Ghost has everything you need to display your content in simple and accurate ways.

To deploy it, you’ll have to use the JavaScript tools Grunt and Bowser. Don’t worry if you don’t know what it is or how to use it, I’ll explain later.

As for the blog data, it’s stored in a sqlite3 database.

Here is the installation procedure is for Debian Wheezy. If you don’t know your Linux distribution, you can type this in a terminal to find out:

cat /etc/*-release

You can follow this installation guide for both production and development mode.

First things first: create a new user

If you have a user who can run Ghost (everybody except the root user), connect to your server terminal with it and jump to the next step.

If not, you have to create a new user. Type these lines in your command prompt:

useradd <username> -d /home/<username> -G sudo
passwd <username>

The first line will create a new user (with its own home directory and add it to the group of sudo users) and the second will set its password.

Let’s connect with it. Type :

su <username>

Go to your web root directory. By default, it’s var/www/ but it’s not recommended to use this path for Ghost or any other website.

Installing nodeJs and sqlite 3

To find out if nodeJs is installed on your server, type this in the terminal:

node -v

If it’s installed, It’ll show you which version of nodeJs you have. Note that you can do the same thing for many other programs.

Getting the last version of Ghost

Now that you have your root folder for Ghost, we’ll use git to pull it.
Git is a very popular version control system. To find out if it’s installed on your server, you know now what you have to do : git -v.

In order to install it, you have to type this in the console:

sudo apt-get update
sudo apt-get install git

Then, to get the latest version of Ghost, just type:

git clone https://github.com/TryGhost/Ghost.git .

You are now on the master branch of the Ghost project. Be careful: this is a version that’s still in development and is not the same as the stable version. Using the development version on a production server is out of the question.
If you don’t plan to participate in the development of Ghost itself, you should use the last stable version even on a development server.

Let’s checkout the stable version of Ghost. To do so, use:

git checkout stable

To install all the NodeJs module’s dependencies, use this command:

npm install

Ok I’m grunting…

Grunt is a task runner for JavaScript projects. With this tool we can automate tasks, like managing dependancies with Bower.

Ghost uses it so we have to install it. Type in your console:

sudo npm install -g grunt-cli

npm stands for Node Package Manager: it was installed with node. With this tool, we can install a node module like grunt. We have two different ways to do it: we can install the module locally or globally.

When you use npm for a local install, it will be put in the project’s node_modules folder. Here we are performing a global install (the option -g means globally).

When it’s done just type:

grunt init
grunt prod

All right. If you haven’t gotten any error, let’s move forward.

Editing the config.js

Use nano or another text editor to edit the config.js file:

nano config.js

You have to change the example domain http://my-ghost-blog.com with your domain name.
Change it for both development and production.

As you can see in this file, the output port for Ghost is 2368, and to put your blog online we need port 80.

Apache already uses port 80 and if you have it installed on your server, you have to add an apache vhost.

Note that you can use nginx instead of apache.

Creating an apache vhost

Go to /etc/apache2/sites-available to create a vhost (just create a text file) and enter the following: