Install KeystoneJS on an Ubuntu 14.04


install-keystonejs-on-an-ubuntu-14-04In this blog post we will show you how to install KeystoneJS on an Ubuntu 14.04 VPS with the latest version of Nginx as a reverse proxy. KeystoneJS is a Node.js content management system and web application platform built on MongoDB and Express. This guide should work on other Linux VPS systems as well but was tested and written for Ubuntu 14.04 VPS.

Login to your VPS via SSH

ssh [email protected]

Update the system and install necessary packages.

[email protected]:~# sudo apt-get update && sudo apt-get -y upgrade
[email protected]:~# sudo apt-get install python-software-properties

Install Node.js

We will install the latest nodejs package from Chris Lea’s repo.

[email protected]:~# sudo add-apt-repository ppa:chris-lea/node.js
[email protected]:~# sudo apt-get update
[email protected]:~# sudo apt-get install nodejs

Install MongoDB

We will install the latest mongo package from the official MongoDB repository.

[email protected]:~# sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
[email protected]:~# echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
[email protected]:~# sudo apt-get update
[email protected]:~# sudo apt-get install -y mongodb-org

Install KeystoneJS

We will install KeystoneJS using the KeystoneJS generator made with Yeoman.

[email protected]:~# sudo npm install -g generator-keystone
[email protected]:~# mkdir ~/myKeystoneApp
[email protected]:~# cd ~/myKeystoneApp
[email protected]:~# yo keystone

The generator will ask you a few questions, install all npm dependencies and configure and copy all the files into the newly created project.

When the installation is finished, run the following to start the KeystoneJS:

[email protected]:~# node keystone

If you see the below message, it means you’ve successfully installed KeystoneJS.

------------------------------------------------
KeystoneJS Started:
My Site is ready on default port 3000
------------------------------------------------

Stop the process with Control-C and continue with the Forever installation.

In case you never heard of Forever, it is a tool which ensures that a given script runs forever.

[email protected]:~# sudo npm install forever -g

Now you can use forever to start your KeystoneJS instance.

[email protected]:~# cd ~/myKeystoneApp
[email protected]:~# forever start keystone.js

Install and Configure Nginx

The latest version of Nginx 1.6.2 is not available via the default Ubuntu repositories, so we will add the “nginx/stable” PPA, update the system and install the nginx package.

[email protected]:~# sudo add-apt-repository ppa:nginx/stable
[email protected]:~# sudo apt-get update
[email protected]:~# sudo apt-get install nginx

Create a new Nginx server block with the following content

[email protected]:~# sudo nano /etc/nginx/conf.d/myKeystoneApp.com
server {
    server_name myKeystoneApp.com;
    listen 80;

    access_log /var/log/nginx/myKeystoneApp-access.log;
    error_log /var/log/nginx/myKeystoneApp-error.log;

    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:3000;
    }
 
}

Test the Nginx configuration and restart the server

[email protected]:~# sudo nginx -t
[email protected]:~# sudo /etc/init.d/nginx restart

That’s it. Now open your browser and type the address of your website ex: http://myKeystoneApp.com.

For more information about how manage your KeystoneJS application ,please refer to the KeystoneJS website.


Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Tutorials
Install Lychee on an Ubuntu VPS
Tutorials
How to install and configure AVG free anti-virus on an Ubuntu VPS
Tutorials
Deploy CiviCRM in conjunction with Drupal on an Ubuntu 14.04 VPS

 
Free Migration to RoseHosting. Award Winning Linux VPS Hosting with Fully Managed Support. Coupon RHBLOG50 for 50% offOrder Now
+