Setup a VPS

To get started, we will need a droplet - the smallest instance will do just enough - and a SSH client (ie. Putty on Windows, Linux systems and Mac Os X usually have it out of the box). When we receive our initial root password, we can ssh into the instance. SSH into the VPS and change the root password, if you haven't already. It would probably be a good idea to also update software repository to the latest versions:

yum -y update

This will update installed software on our VPS to the latest versions.

Yum can take a few minutes, but when it's done, we need to prepare for software installation. We're going to build Node.js from the latest source available at the moment of writing this (v0.10.4). To do that, we'll need "Development Tools". It's a group of tools for compiling software from sources.

yum -y groupinstall "Development Tools"

This command will pull a "Development Tools" group with the applications needed to compile node.js.

Also, we'll install GNU screen - a piece of software that allows us to connect to our VPS, start a session and detach from it. We could disconnect and connect later, or from another workstation, and pick up where we left. It's very handy, especially during development of an app, when we want to learn stuff.

yum -y install screen
 

Node.js installation

Now that we're ready to install Node.js from sources. First, we'll move to /usr/src directory - the usual place to hold software sources.

cd /usr/src

Now, we pick the latest compressed source archive from Node.js website at http://nodejs.org/download/.

wget http://nodejs.org/dist/v0.10.4/node-v0.10.4.tar.gz

We could and should replace the url and use the more recent version of node.js, if there is one. Next, we are uncompressing the source files and move into that directory.

tar zxf node-v0.10.4.tar.gz
cd node-v0.10.4

Now the source for Node.js is extracted and we're in the source directory. We can now prepare our compiler commands, by executing the configure script:

./configure

It will read the properties of our system to prepare compiler flags. Ie. it could be a system architecture (32/64bit, CPU specific flags etc). With it, we're ready to actually compile the source now. To do that, just type:

make

This is probably the most time-consuming task here: on my example VPS it took about 6 minutes and 34 seconds to complete. When we're done, we need to make this available system-wide:

make install

The latest command will place the compiled binaries in system path, so all users could use it without any further setup. By default, node binary should be installed in /usr/local/bin/node.

To enable the winsock js, type

npm install ws