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.

9 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.

  4. domain says:

    Hi it’s me, I am also visiting this website daily, this website
    is actually good and the visitors are truly sharing nice thoughts.

  5. Niamh says:

    Thanks for sharing your thoughts. I really appreciate yoսr effortѕ and I will bee waiting for your next write ups thank you
    once again.

  6. Discover music directories as well as publish your movies or if your website.
    The film is done in the traditional 2D animation style, which has largely
    become passe in this country. Apparently, one guy moved
    the enclosure without permission from the other, and now one fellow has a bullet hole in him, and the other is
    imprisoned in his own home.

  7. So, just embrace the virtual world of movies, and avail this brilliant chance to treat yourself to
    the best that can be, of watching movies. The film is done in the traditional 2D animation style,
    which has largely become passe in this country. Other players have
    limits, such as Megavideo or Megadownload which has a time limit on how long you can view videos
    without paying for service.

  8. Tiffany says:

    Nevertheless, hefty customers of those devices will certainly be in require
    of backup energy materials and supplying them by having
    an stock of battery chargers and battery packs will probably be a
    effective enterprise in fact. If you are not a developer, but want to
    develop one of the best Android Game Development
    for your device, simply Hire Android Game Developer from the popular Android Game Development Company.
    There is an integrated micro – SD card slot which comes
    with a pre-installed 2 GB memory card, however this can be replaced
    with a memory card of up to 16 GB meaning users have the
    potential to store a large number of files be they photos, videos, music or documents.

  9. One more thing to note is that the game economy has been drastically altered in this expansion. Trading Card Game, was released as a 60 card set in North
    America on December 1, 2014. Both have their benefits and disadvantages;
    however, the degree of fun Asian online casinos carry is equivalent, if not, can exceed that
    of the actual casino.

Got something to say? Go for it!