How to Install nodejs server on EC2 AWS centos 6

Hey,

Download nodejs server from source 
http://nodejs.org/download/
Look for the "Source Code" and copy the link.

cd /usr/src
wget http://nodejs.org/dist/v0.10.26/node-v0.10.26.tar.gz
tar -xzvf node-v0.10.26.tar.gz
Now before compiling , lets install the relevant dependencies.
yum -y groupinstall "Development Tools"
yum -y install screen

Right now let's enable the epel repository 
vim /etc/yum.repos.d/epel.repo
#change to enabled=1
yum install js-devel
yum install curl-devel
yum install autoconf-archive
yum install libicu-devel





Now let's Configure
./configure
make
make install
 
Now test it with a 'test' nodejs app


cd /root
vim test.js



pase this code



// Load the http module to create an http server.
var http = require('http');

// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.end("Hello World\n");
});

// Listen on port 8000, IP defaults to 127.0.0.1
server.listen(8000);

// Put a friendly message on the terminal
console.log("Server running at http://127.0.0.1:8000/");
 



and now run

nohup node test.js > node.log 2>&1 &

check it with 

curl http://127.0.0.1:8000/

and check the node.log 

you can also manage the nodejs process with supervisord


Amiram.
Advertisements
Tagged with: , ,
Posted in NodeJS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: