I sometimes describe dynamic web applications (PHP or ASP.NET) as 1 ½ tier applications.

Really all the application logic runs on one server (sometimes the database lives on a separate server with some logic in Stored Procedures) and the browser is the “client”. But in those applications the “client” is really not a client in the client server sense. It’s the TERMINAL.

The more we federate logic in our web applications to the user’s machine (inside or outside of the browser) the more we take load responsibility away from our server infrastructure.

I think NODE.js is a great potential alternative for the server side piece of a real web based client / server scenario.

However, in searching the web you find lots of posts about how to install NODE.js that are pretty intimidating.

I found it very easy to set up on Ubuntu so I thought I’d share the steps in case anyone would find them useful.

You can do the install on Ubuntu 11.10 using the Synaptic Package Manager.

On the Ubuntu Unity tool bar, click on the “Dash home” icon at the top of the bar.

Start typing “Synaptic” to search for the package manager and when it appears, click to fire up the Synaptic Package Manager.

In the Synaptic Package Manager enter node.js into the package search box.

As you see above, select NODE.js (I also selected the developer and debug packages) and then click on the “Apply” button.

When you’re done the Package Manager Dialog should look something like the one above.

Then open up text editor (in the image below, I’m using Geany)

Enter just the seven lines of code shown above which will serve as a test to confirm that NODE.js is installed correctly.

var http = require('http');

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('NOTICE : Node.js is Running !!!\n');
}).listen(8100, "");

console.log('Server running at');

Now save the file where you want to execute it from.

I saved mine in the default directory for web content (/var/www/hello_node.js)

Once you have saved the file, open up a terminal window and go to the directory where you saved the file.

(Type “cd /var/www” and hit return.)

Then list the directory to make sure you newly created file is there.

(Type “ls” and then hit return.

Assuming all has gone well up to this point, type in the following command and hit return.

“node hello_node.js”

You should see the “Server Running” console trace message from our hello_node.js file as you see in the screenshot below.

Now open your browser (GetfireFox.com) and navigate to http://localhost:8100

8100 is the port we told our little app to listen on.

And there you go. We’re ready to start digging in to NODE.js

I’ll try to add instructions for Mac and Windows in the near future.