Installing Node.js on CentOS/RedHat

Node.js, if you are not yet familiar with it, facilitates building event-driven server-side javascript services. Services built with Node.js go to sleep after instructing the operating system to wake them if a connection is made (via epoll, kqueue, /dev/poll or select). Additionally, each connection is only a small heap allocation, as opposed to spawning a 2M thread/child for each connection like some other popular web services.

Node.js is a server-side JavaScript environment that uses an asynchronous event-driven model. This allows Node.js to get excellent performance based on the architectures of many Internet applications.

The event-driven model and Node.js framework makes it ridiculously simple to build web services like the following “Hello World” example from the Node.js webpage:

var http = require('http');

http.createServer(function (request, response) {
  response.writeHead(200, {'Content-Type': 'text/plain'});
  response.end('Hello World\n');
}).listen(8124);

console.log('Server running at http://127.0.0.1:8124/');

Installation

The online wiki provides instructions on installing Node.js as an unmanaged package, but I prefer to handle as much as possible with RPM. To that end, I put together a simple spec file that can be used to build Node.js RPMs for use on RedHat or CentOS systems (or any other system that uses RPM as a package management tool).

The first thing you’ll need to do is download the latest Node.js source package. At the time of this writing, v0.4.6 is the most current version of Node.js available. I like to use curl to download the sources directly into the default rpm sources directory, but you could also use wget or simply download the package via your web browser. You’ll also need to make sure that Node.js source ends up in the right place if you are not building the RPM as root, or if you like to put your build structure somewhere other than /usr/src/redhat.

curl -sR -o /usr/src/redhat/SOURCES/node-v0.4.6.tar.gz \

http://nodejs.org/dist/node-v0.4.6.tar.gz

Once you have the source in place, download the Node.js spec file and place it into /usr/src/redhat/SPECS (or the appropriate spec folder). To build the RPM, execute rpmbuild as follows:

rpmbuild -ba /usr/src/redhat/SPECS/nodejs.spec

Once the build completes, you will find your RPMs in the /usr/src/redhat/RPMS folder.

More Information

For more information about Node.js, visit the following online resources:

Chris Abernethy
PHP Wrangler, MySQL DBA, Linux SysAdmin and all around computer guy, developing LAMP applications since Slackware came on 10 floppy disks.

3 Comments on "Installing Node.js on CentOS/RedHat"

  1. Hello, its fastidious paragraph about media print, we all know
    media is a great source of information.

  2. It was a defence witness in the image of a study about premonitions:
    A Phenomenological Examination of Premonition in Dreams and Waking State: A Survey
    Study Australian Journal of Parapsychology, 2013. But having opened up, under psychic experiences any circumstances.
    So I started a foundation called The Nihewan Foundation for
    American Indian Higher Education Consortium.

  3. Heya i am for the primary time here. I found this board and
    I find It really helpful & it helped me out much. I hope to give something back and help others such as you aided me.

Got something to say? Go for it!