Linux下安装node.js步骤
1,1 下载node.js的安装包
wget
1,2 解压安装
tar -zxvf node-v0.8.7.tar.gz
cd node-v0.8.7
./configure --prefix=/usr/local/node.js
make && make install
1,3 配置路径
修改~/.bash_profile文件
NODE=/usr/local/node
PATH=$PATH:$NODE/bin
export PATH
source ~/.bash_profile
1,4 测试
测试一:
hello.njs
console.log('hello world’);
执行:
node hello.njs
测试二:
server.njs
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at ');
执行:
node server.njs &
浏览器中输入:
阅读(662) | 评论(0) | 转发(0) |