node.js 学习

sudo apt-get install g++ curl libssl-dev apache2-utils 
sudo apt-get install git-core 

git clone git://github.com/ry/node.git  (下载原码)

然后

./configure 
make 
sudo make install 

 

编写如下小程序,命名为example.js,保存在node文件夹下。

var http = require('http'); 
http.createServer(function (req, res) { 
res.writeHead(200, {'Content-Type': 'text/plain'}); 
res.end('hello world'); 
}).listen(8124, "127.0.0.1"); 
console.log('Server running at http://127.0.0.1:8124/'); 

 

执行node example.js 

 

 

 

posted @ 2012-01-06 17:55  wtx  阅读(265)  评论(0编辑  收藏  举报