您的位置:首页 > 运维架构 > Linux

centos安装node.js

2013-08-21 17:31 459 查看
确保安装了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 ' target='_blank'>http://192.168.8.204:8001');[/code] 
运行:node hello.js

在浏览器里输入 http://192.168.8.204:8001/,可以看到 "hello world"字样



注:监听IP地址(192.168.8.204)可以省略
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: