Node.js chapter 1: Installation on linux server

Node.js is a server-side software system designed for writing scalable Internet applications. Programs are written on the server side in JavaScript. Node.js creates a web server by itself, making it unnecessary to use web server software such as Apache or Lighttpd and allowing full control of how the web server actually works. Node.js enables web developers to create an entire web application on both server-side and client-side in JavaScript.

Nodejs

Configure node.js on linux CentOS server

Step 1:

Here we will see how to install Node version 0.10.4 on linux server. First check version of Python library installed on your server it should be Python 2.7. Now download Node.js and untar it using following commands.

wget http://nodejs.org/dist/v0.10.4/node-v0.10.4.tar.gz tar zxf tar node-v0.10.4-darwin-x86.tar.gz cd node-v0.4.11

Step 2:

After untar it and you need to configure it using following command

./configure

Once you fire above command you will see output like this. There may be possibility about missing required libraries, if there is any you need to install those like GCC or OPENSSL

Step 3:

After this make you node build using following command

make

Step 4:

After creating make successfully, install that using following command

make install

Now you are done, Node is installed on your server. To verify node is installed or not use following command to check the version.

node -v

Node.js has a package manager, called Node Package Manager (NPM). It is automatically installed with Node.js, and you use NPM to install new modules. NPM already has too many useful packages. Before you you create you new node program its necessary to create new module so your program will install under that module. To install a module. Execute following command to create new module:

npm install module-name

Like we do for every program lets check node with hello message. Now create hello.js on server and add following code.

// Call the console.log function. console.log("Hello Node!");

This program will print “Hello Node!” in your console. Fire following command to run this file

node hello.js

Socket server program will be coming soon.