Ghost installation for Raspberry Pi…

Standard

Ghost is a new blogging platform. It has a refreshingly innovative and responsive UI – one that can clearly be seen as the future of blogging. You might want to visit Ghost’s website to know more about it. I promise, once you’ve learnt how it works, you won’t stop thinking about it. While you’re at it, do learn how it’s installed on the Raspberry Pi from our tutorial below.

GhostGhost runs on Node.js and, like WordPress, is free to download and use. It is expressly intended to be a blogging platform unlike the recent evolution of WordPress.

Wait! Node.js?!

500px-Node.js_logo.svg

Node.js is an event driven system that is written in Javascript and C++. It is known for its non-blocking I/O system and higher response speed with simultaneously lesser resource consumption. Node.js is widely used in chat web application, but can definitely do a lot more like handling entire blogs as it would with Ghost.

Installation of Ghost

There are a lot of operating systems available for the Raspberry Pi but, for this, we recommend using Raspbian. The rest will be a breeze.

1. Install Node.js

You will have to have Node.js installed on your Raspberry Pi. As a matter of fact we’ve written a tutorial on how you can do just that right here.

2. Acquire the Ghost setup

Download the package

To install Ghost, it’ll need to be download from the official website. Do that by entering the following in the terminal.

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

Unzip the package

Now that the package has been downloaded, it will have to be unzipped. You can simply do it by entering the command.

unzip ghost-latest.zip -d ghost

The package contents will fill a new directory by the name ghost.

3. Focus on the new folder

To set the Ghost folder ghost as current directory use the command.

cd ghost/

4. Install Ghost from the setup

After focusing on the ghost directory, we need to install it using NPM by entering the command below.

sudo npm install --production

5. Install a database management system

For your database management system you can choose your favourite one and use it with Ghost. We ourselves have done it a few times with MySQL and MariaDB. We’ve gone for SQLite for this tutorial – the Ghost configuration file by default uses SQLite. You can install SQLite3 using the command below.

sudo apt-get install sqlite3

6. Edit the configuration file

If you use MariaDB, MySQL or a different management system make the appropriate changes to the settings in config.js file of the Ghost setup.

Edit the config.js file to change the default host: and set the port: to 80 as seen below. That is, of course, unless you’re fine with using the default settings.

host: '0.0.0.0'

port: '80'

7. Set up Forever

Once we’re done editing config.js, we need to install Forever so we could continue running the Node.js web-server after the end of the SSH session.

Install forever

Enter this command.

sudo npm install forever -g

Set Node.js to run with Forever

This will let Node.js continue running despite being in production mode. Enter them one after another.

sudo NODE_ENV=production forever start index.js

sudo forever index.js --production

And that’s it!

You’ll have successfully created a Raspberry Pi hosted Ghost blog on its Node.js web server.

You’ll have to visit [the-IP-address-of-your-Raspberry-Pi]/ghost/ to access the process of creating your user account the first time. The process takes a while because the password is hashed using Bcrypt. Once done, that URL acts as your Ghost admin panel.

The blog can be accessed as a non-admin viewer using your Raspberry Pi’s IP address.

Cool, isn’t it?! Do leave us comments if you’ve decided to give it a try or have tried alternate methods for installation. Feedback is always appreciated. Do stay tuned for more on Ghost in the future…

Node.js installation for Raspberry Pi…

Standard

Node.js is a brilliant platform for creating network applications. It is mainly known for its non-blocking I/O and event driven system. In simple terms, Node.js can easily handle a large number of requests while simultaneously consuming lesser server memory. These are the attributes one should be looking for in a low power server like, you guessed it, Raspberry Pi. Here, you’ll learn how to setup Node.js for Raspberry Pi.

Node.js

ON

Raspberry Pi

Why use Node.js?

Node.js comes with a built in HTTP server library. This means it doesn’t require the help of any external piece of software to act as a web-server. Using Node.js alone one can have greater control of the web-server parameters.

Of course, all we care about it tinkering. Cool new web applications require Node.js to function and we like our Raspberry Pi not being a source of heat all the time. Of course, you could check the Wikipedia entry as well as their very own site.

Installing Node.js on Raspberry Pi

1. Download the Node.js package for ARM

As you must be aware, the Raspberry Pi sports an ARM11 chip. So, the package optimised for ARM will have to be downloaded. It can be done by entering the following command into the terminal.

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

2. Install the package

Once the download is complete, it needs to be installed and can be done using the following command.

sudo dpkg -i node_latest_armhf.deb

And that’s it! Quick, wasn’t it?

By its end, we will have NodeJS and NPM (Node Package Manager) installed on your Raspberry Pi.

Testing the installation

The process is pretty foolproof but it wouldn’t hurt to test the installation with a simple server script.

1. Write the server script

Below, we have written a script that displays “Hello World!” to the client.

var http = require('http');
http.createServer(function (request,response) {
 response.writeHead(200, {'Content-Type': 'text/plain'});
 response.end('Hello World!\n');
}).listen(8000)
console.log("Web Server running at http://127.0.0.1:8000")

Update: There’s a chance the code might not appear in with proper line-breaks on your PC. So, here below we’ve enlisted the above code in its right syntax:

#### Save the script in a file

Save the script in a .js javascript file. Something like greetings.js would be a good idea if you’re not feeling particularly creative.

2. Run the script

Use the node program from the command line to execute the server. Something like so.

node greetings.js

You’ll receive an output like this.

Hello World!

If you’d like you could visit http://127.0.0.1:8000 and be greeted “Hello World!”.

And that is that!

Stay tuned for more on Raspberry Pi, Node.js and all of the web-apps based on it. Do leave us comments if you’d like us to do anything for you…