Sunday, December 11, 2011

Node.js on Linux

The steps for installing node.js on linux

1. To install the tools needed to build node open a terminal and type the following commands:
sudo apt-get install g++ curl libssl-dev apache2-utils git-core

2. Then checkout the node source:
git clone git://github.com/ry/node.git

or
git clone git://github.com/joyent/node.git



3. Change into the node directory
cd node

4. Configure the compiling process
./configure

5. Compile node.js:
make

6. Install it:
sudo make install

7. Set up a test directory:
cd ..

mkdir hello_node

cd hello_node

8. Make a test server file:
gedit hello_node.js

9. In the file enter the following codes:
var http = require(‘http’);
http.createServer(function(req,res){
res.writeHead(200,{‘Content-Type’:’text/plain’});
res.end(‘Hello this is node.js\n’);
}).listen(8000,”127.0.0.1”);
console.log(‘Server running at http://127.0.0.1:8000’);

10. Save the file and run it by typing
node hello_node.js

11. Now go to the browser and type http://127.0.0.1:8000

1 comment:

  1. Lucky Eagle Casino & Hotel - Temecula, MS - JM Hub
    JM Rewards · Play Blackjack · Jackpots · Cash games · Live casino · Live 경상북도 출장샵 table games · Blackjack. JCMH is the world's 공주 출장안마 leading 경산 출장마사지 casino 전주 출장마사지 operator. 밀양 출장샵 We have over 1,500 games

    ReplyDelete