Installing Node.js on a CentOS Linux Virtual Machine in Windows Azure

First I created a CentOS Linux Virtual Machine with host names as “nodejsbox” and the DNS name as https://nodejsbox.cloudapp.net

 

 

As I will use this machine as node.js web server so I have added https endpoint for protocol TCP at port 80 as below:

 

 

Now I can log into my Linux machine by following instructions as directly here How to Log on to a Virtual Machine Running Linux.

After that I ran the following commands:

$ sudo –i
Entered my password

Installing stable release of node.js directly from node.js repo

[root@nodejsbox ~]# wget https://nodejs.tchol.org/repocfg/el/nodejs-stable-release.noarch.rpm
[root@nodejsbox ~]# yum localinstall --nogpgcheck nodejs-stable-release.noarch.rpm
[root@nodejsbox ~]# yum install nodejs-compat-symlinks npm

Verify that node is running in my machine:

[root@nodejsbox /]# node --version
v0.6.18

Now created a folder name nodeserver at /usr/local and then created server.js as below:

# cd /usr/local
# mkdir nodeserver
# cd nodeserver
# vi server.js

var http = require("http");
http.createServer(function(request, response) {
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.write("Hello from Node.js @ Windows Azure Linux Virtual Machine");
  response.end();
}).listen(80);

 

Finally launch node.js

[root@nodejsbox nodeserver]# node server.js

 

You can verify that your node.js is running on Linux machine:

 

Keywords: Windows Azure, Node.js, CentOs, Linux, Virtual Machine