`

centos 安装 Node.js 0.8.5

 
阅读更多

 

centos 安装 Node.js 0.8.5

node.js 0.8.5的安装,需要python 2.7,大部分安装失败,都是因为python版本过低所致。安装之前,请升级python版。升级步骤http://sailinglee.iteye.com/blog/1631033

 

[tom@MyVPS1974 ~]$ python -V
Python 2.7.3

 

开始安装:

 

wget http://nodejs.org/dist/v0.8.5/node-v0.8.5.tar.gz
tar zvxf node-v0.8.5.tar.gz
cd node-v0.8.5
./configure
make && make install

 

写一段小程序例如hello_node.js来验证安装是否正确:

 

var http = require('http');

http.createServer(function (req, res) {
  res.writeHead(200, {
    'Content-Type': 'text/plain'
  });
  res.end('Hello Node.js');
}).listen(8124, "127.0.0.1");

console.log('Server running at http://127.0.0.1:8124/');
 

用node来运行这段代码

 

[tom@MyVPS1974 ~]$ node hello_node.js
Server running at http://127.0.0.1:8124/

现在,用浏览器打开 http://127.0.0.1:8124/ , 应该能够看到一条消息。

 

[转自:http://cnodejs.org/topic/501ddec0f767cc9a51bad53c]

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics