摘要:linux上的nodejs安装与小例演示。
安装
[hadoop@hadoop01 node-v6.11.3]$ sudo yum install -y nodejs
[hadoop@hadoop01 node-v6.11.3]$ node -v
v0.10.48
小例代码
var http = require('http');
var server = http.createServer(
function(req,res){
res.writeHeader(
200,{'Content-Type':'text/html; charset=utf-8'}
);
res.write('<h1>hello happyprince</h1>');
res.end('<a href="http://blog.csdn.net/ld326"><font color=red>http://blog.csdn.net/ld326</font></a>');
});
server.listen(9999,'hadoop01',function(){
console.log('running hadoop01:9999');
});
服务器运行
[hadoop@hadoop01 testData]$ node server.js
running hadoop01:9999
web查看
【作者:happyprince; http://blog.csdn.net/ld326/article/details/78035345】