Node.js安装

最近看几个朋友都在研究node.js,今天自己也安装个测试测试。

安装环境为:

Vmware虚拟的CentOs6.0, 安装步骤:

1.安装Gcc

yum install gcc-c++ openssl-devel  

wget --no-check-certificate https://github.com/joyent/node/tarball/v0.3.3

2.下载node.js,从官网找最新到版本下载,我下载的版本是:

wget http://nodejs.org/dist/v0.6.14/node-v0.6.14.tar.gz

3.解压编译安装

tar -zxvf node-v0.6.14.tar.gz

cd node-v0.6.14

make && make install

4.测试安装的是否成功

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/');

5.执行浏览

node node.js

Server running at http://127.0.0.1:8124/

网页中输入:http://127.0.0.1:8124

你可以看到:Hello Node.js



原文地址:https://www.cnblogs.com/beceo/p/2432231.html