确保安装了python,大部分安装失败都是由于python版本过低导致。安装之前,升级python版本,升级步骤 http://www.tomtalk.net/wiki/Python。
[root@SNDA-192-168-15-161 ~]# python -V
Python 2.7.3
开始安装:
1、安装node.js--v0.11.5
wget http://nodejs.org/dist/v0.11.5/node-v0.11.5.tar.gz
tar -zxvf node-v0.11.5.tar.gz
./configure
make && make install
make && make install 时间会稍微长一点
2、测试
创建hello.js文件,内容如下:
var http=require('http');
http.createServer(function(req,res){
res.writeHead(200,{'Content-type':'text/plain'});
res.end('hello world\n');
}).listen(8001,'192.168.8.204');
console.log('Server running at http://192.168.8.204:8001');
运行:node hello.js
在浏览器里输入 http://192.168.8.204:8001/,可以看到 "hello world"字样
注:监听IP地址(192.168.8.204)可以省略