node.js在Ubuntu 12.04下的安装和配置
node.js在Ubuntu 12.04下的安装和配置准备一些包sudo apt-get install g++ curl libssl-dev apache2-utilsgit是不可少的sudo apt-get install git-core用git下载node.js最新版git clone git://github.com/ry/node.git或者直
·
node.js在Ubuntu 12.04下的安装和配置
准备一些包
sudo apt-get install g++ curl libssl-dev apache2-utils
git是不可少的
sudo apt-get install git-core
用git下载node.js最新版
git clone git://github.com/ry/node.git
或者直接下载源码
wget http://nodejs.org/dist/node-v0.10.2.tar.gz
gunzip node-v0.10.2.tar.gz
tar -xf node-v0.10.2
开始编译安装node.js
cd node-v0.10.2
./configure
make
sudo make install
输入node –v 或者node –version可以查看node.js当前的版本
运行第一个node.js的程序
在主文件夹中创建example.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 example.js
浏览器中浏览,浏览器中出现hello node.js
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
已为社区贡献2条内容
所有评论(0)