Linux Administrator

How to Install Node.js on CentOS-6/RHEL-7

Written by Santosh Prasad

Node.js is a server-side platform built on Google Chrome’s JavaScript Engine (V8 Engine). Node.js was developed by Ryan Dahl in 2009 and its latest version is v0.10.36. Node.js is an open source, cross-platform runtime environment for developing server-side and networking applications. Node.js applications are written in JavaScript, and can be run within the Node.js runtime on OS X, Microsoft Windows, and Linux.

Node.js Features

Following are some of the important features that make Node.js the first choice of software architects.

  • Asynchronous and Event Driven − All APIs of Node.js library are asynchronous, that is, non-blocking. It essentially means a Node.js based server never waits for an API to return data. The server moves to the next API after calling it and a notification mechanism of Events of Node.js helps the server to get a response from the previous API call.
  • Very Fast − Being built on Google Chrome’s V8 JavaScript Engine, Node.js library is very fast in code execution.
  • Single Threaded but Highly Scalable − Node.js uses a single threaded model with event looping. Event mechanism helps the server to respond in a non-blocking way and makes the server highly scalable as opposed to traditional servers which create limited threads to handle requests. Node.js uses a single threaded program and the same program can provide service to a much larger number of requests than traditional servers like Apache HTTP Server.
  • No Buffering − Node.js applications never buffer any data. These applications simply output the data in chunks.
  • License − Node.js is released under the MIT license.

In this tutorial I will show how to install node.js on CentOS6/RHEL7 machine.

Install Node.js on CentOS6/RHEL7

Follow the below steps to install node.js on CentOS6/RHEL7 machine.

1. Install Required Packages

Run the below command to install all required packages.

# yum install gcc gcc-c++ wget

After installing require packages the development tools and screen package in your system using following commands.

# yum groupinstall "Development Tools"
# yum install screen

2. Install Python

You will need to install Python 2.7 or above for latest version of node.js. So make sure you have installed proper Python version. You may also refer following article to install it.

How to Install Python 3.5?

3. Download Node.js

Now download the latest node.js code as shown below.

# cd /opt
# wget
# tar xzf node-v5.8.0.tar.gz
# cd node-v5.8.0

4. Extract and Compile Node.js

Now we have extracted source of node.js and use one of below command to compile source code. If you have install Python 3.5 alternatively use second one.

# ./configure
# python3.5 ./configure 

./configure actually not compiles the source code, it only sets the compiler flags as per your system architecture ( 32/64bit ). now use below commands to actually compile the code. These commands may take more time to complete.

# make
# make install

5. Verify Node.js Version

Run the below command to verify the node.js version.

# node --version

6. Configure Example Application using Express

Run the below command to install required nmp modules.

# npm -g install express supervisor express-generator

This time is to create application using express and npm using below set of commands

# express technical
# cd technical
# npm install 
# screen

The above commands will create a directory myapp and npm will install all the required modules to run your application from its software repository.

Now edit views/index.jade and add following content to show on default page.

# vim views/index.jade

extends layout

block content
  h1= title
  p Welcome to LookLinux World

Now restart your application using supervisor.

# supervisor ./bin/www

This application by default start on port 3000. Access your application by connecting your server on port 3000 in your browser.



Thank you! for visiting Look Linux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website To become an author at Look Linux Submit Article. Stay connected to Facebook.

About the author


Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment