Setup Node.js server on Amazon EC2

Three useful links:

Here is what I did after logon to my first EC2 instance:

sudo yum update
sudo yum install gcc-c++ make
sudo yum install openssl-devel

tar xzf node-latest.tar.gz
cd node-v0.10.30
./configure && make && sudo make install

To verify the setup, I created the following server.js:

var http = require("http");
http.createServer(function(request, response) {
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.write("Hello World");

After executed:

node server.js

The link http://localhost:8888/ should display a web page that says “Hello World”.

Steps to install npm:

sudo su
nano /etc/sudoers

Once inside the Nano editor, scroll to where you see the line:

Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin

Append the following value, “:/usr/local/bin”, to the end of that line. Save the file and exit the Nano editor.

git clone
cd npm
sudo make install

Leave a Reply

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

You are commenting using your 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 )

Connecting to %s