Tips / Nginx

How to install NodeJS on CentOS 7.x


Node.js is a Javascript platform built to help developers to create fast and rich Javascript applications. It allows users to build apps that require back-end functions using Javascript on the server side. On this tutorial I will show you how to install NodeJS on CentOS 7 server using two methods: compiling from source files, and using rpm files from EPEL repo.

Tutorial requirements:

  • NodeJS must run on a VPS or Dedicated Sever, I can recommend you this great providers where you can buy cheap hosting with very good technical support:
    • A Small Orange
    • A2 Hosting
  • Basic compiler tools can be installed using this command:
yum install gcc gcc-c++

Installing NodeJS on CentOS 7.x using source files

Get the Node files, extract, compile and install:

tar xvpzf node-v*
cd node-v*

Configure & Compile NodeJS:

make install

Check if NodeJS was installed properly:

node --version

It should show you the last version number.

Installing NodeJS using EPEL repo

An easy method for most users is to use EPEL repo (Extra Packages for Enterprise Linux) that allows CentOS and RHEL users to get the lastest and most fresh software that the stable versions doesn’t have.

Add the repository:

rpm -Uvh  epel-release-6*.rpm

Now install NodeJS using yum:

yum install nodejs

Check if the installation was ok:

node --version

If you want access to the NPM console in order to install more NodeJS modules, you can do it by typing:

yum install npm

Now you are ready to start working with NodeJS and run your JS applications on the server side.


Testing Hello World on NodeJS

This script responds with the classic “Hello World” when you run it.

Let’s create it:

nano -w example.js

Paste this code inside:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello Worldn');
}).listen(1337, '');
console.log('Server running at');

To run the new webserver you just created, you only need to call the example.js file with the node commmand, as you see here:

node example.js

It should output something like this:

Server running at

If you need more information, you can read about NodeJS at 

Popular search terms:

  • how to install node nginx
  • cents os NPm ngnix
  • centos nodejs install
  • centos nginx nodejs

Esteban Borges

Linux Geek, Webperf Addict, Nginx Fan. CTO @Infranetworking