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, "127.0.0.1"); console.log('Server running at http://127.0.0.1:8100/');
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.
Hi,
Very good tutorial. Anyway there’s another way to setup node.js :
1- Use the PPA repository to get very last version of nodejs and npm : https://launchpad.net/~chris-lea/+archive/node.js
2- Use this all in one customisable script : http://apptob.org/
I’m a French node.js addict, and I use node.js daily for my job and for fun. Feel free to read my blog : http://www.it-wars.com/categorie8/dev
Regards,
Vincent RABAH
[…] 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 [Read More] […]
[…] News excerpt from: Installing NODE.js on Ubuntu Linux. :MisfitGeek (Joe Stagner) […]
[…] Installing NODE.js on Ubuntu Linux. (Joe Stagner) […]
Hi Joe, thanks for the article & I am really happy to see you up & blogging on the new gig and I’m looking forward to spending time with node.
But why is my ASP.NET app be 1/2 tier less than a Node.js app? And is it really fair to say that ASP.NET & PHP developers are building terminal apps? I spend more time writing JS than C# on most of my ASP.NET apps these days – and the Hanselman ‘Web Stack of Love’ seems like a pretty good platform for creating interactive web sites.
Hi Ras,
It doesn’t have to be, but most developers are not building ASP.NET or PHP sites they way you mention. Most are relying on the framework to generate the client and no real logic execution happens on the client. The more we move to the client, the thinner the back end can become.
Joe,
Is there already any Apache module to let Node.js run under Apache web server?
Cheers.
I don’t know of a module but here is an article on working with them on the same server. http://arguments.callee.info/2010/04/20/running-apache-and-node-js-together/
Thanks for the link in my resource (apptob.org). If you need help admin ubuntu you can contact me.