node.js application deployment

25 Oct 2014


This step-by-step article lists the steps required to install and run a node.js application on a clean Ubuntu 14.04 server.

Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.

nginx (engine x) is an HTTP and reverse proxy server, as well as a mail proxy server. We are going to use it to allow multiple node.js applications to run on the same physical server.

To see how you can prepare a virtual Ubuntu machine on Windows take a look at this post. Git server is described here and has bears some resemblance with this post.

Node Application

On the Windows host computer I installed node.js from here. I've got an error: Error: ENOENT, stat 'C:\Users\%USER%\AppData\Roaming\npm' with npm so I did a

mkdir C:\Users\%USER%\AppData\Roaming\npm

and npm was happy. I installed express globally using

npm install -g express
npm install -g express-generator

A minimal .gitignore can be:


node.js in Server

Create a new user to run node tasks.

sudo adduser noderunner

but don't switch to it, yet. Install npm and node:

sudo apt-get install npm nodejs

In /etc/ssh/sshd_config we may want to allow access to certain users. Add a line like:

AllowUsers git noderunner $YOUR_USER_NAME

su noderunner
mkdir .ssh && chmod 700 .ssh
touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
sudo chmod -R 0750 /home/git
echo "ssh-rsa  ...  rsa-key-20141025" >> ~/.ssh/authorized_keys

Pom to the Rescue

Pod seems like exactly the application for us.

On the server

sudo npm install -g pod

The switch to noderunner user and follow along:

su noderunner

We need a directory for pod stuff, so I called it podstuff:


To create a new application:

pod create myapp

In local computer:

git remote add deploy noderunner@$IP_OR_NAME:~/podstuff/repos/myapp.git
git push deploy master

To check the status use either

pod list

of check $IP_OR_NAME:19999 using a web browser after

pod web

has been issued. The credentials are admin/admin and can be changed in ~/.podrc. See an example config file with all options inhere.


sudo apt-get install nginx
sudo service nginx start

cd /etc/nginx/sites-available
nano myapp

Fill in the content:

Enable the site:

cd ../sites-enabled
sudo ln -s /etc/nginx/sites-available/myapp myapp
sudo rm default

And restart nginx:

sudo service nginx restart


Tagged with walkthrough

"Any sufficiently advanced troll is indistinguishable from a genuine kook." Alan Morgan