安装node.js


centos安装步骤如下:

首先到官网下载:

http://nodejs.org/#download

我选择的版本是0.6.2

# tar zxvf node-v0.6.2.tar.gz

# cd node-v0.6.2

# ./configure

# make

# make install


测试node.js

vim node.js

var http = require('http');

http.createServer(function (req, res) {

res.writeHead(200, {'Content-Type': 'text/plain'});

res.end('Hello Node.js\n');

}).listen(8124, "127.0.0.1");

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

执行node.js

# node node.js

打开浏览器使用连接http:// 127.0.0.1:8124看到“Hello Node.js”,就表示node.js已经正在运作中。





原文地址:https://www.cnblogs.com/whoknows/p/2255165.html