Sunday, June 29, 2014

How to host website using node Js ?

Is it possible to develop a web server functionality using Java Scripting language? Do you believe this, because I didn’t believe in it when I heard about it first.

clip_image001

But the author of node.js Ryan Lienhart Dahl believed and delivered ! Node.js simple yet amazing, give a try!

What Wikipedia says about node Js ?

Node.js is a software platform for scalable server-side and networking applications. Node.js applications are written in JavaScript, and can be run within the Node.js runtime on Mac OS X, Windows and Linux with no changes.

Things that you can do using node.js ?

The HTTP and socket support allows Node.js to act as a web server without additional web server software such as Apache HTTP server.

My Experiment with node.js:

1] Prerequisites :-

clip_image001 Node.js

clip_image001[1] Connect package

2] Server.js content:-

var connect = require('connect');

connect().use(connect.static(__dirname + '/sociogram')).listen(80);

console.log('Server started on port 80');

3] Application folder structure:-

clip_image002

4] Start the server process:-

As mentioned in the js code a server process initiated and it will be keep on listening on port 80.

clip_image004

5] Hosting:-

Snapshot of sociogram application that hosted using node.js server side functionality.

clip_image005

Happy hosting !

No comments:

Post a Comment