Chinaunix首页 | 论坛 | 博客
  • 博客访问: 439729
  • 博文数量: 101
  • 博客积分: 578
  • 博客等级: 中士
  • 技术积分: 872
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-12 22:24
文章分类

全部博文(101)

文章存档

2015年(1)

2014年(83)

2012年(17)

我的朋友

分类: 其他平台

2014-04-07 12:07:54

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 &

浏览器中输入:









阅读(611) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~