近来Node.js很火,于是Hello World一下。
Ubuntu 11.10 安装Node.js的方法,需要的朋友可以参考下。
1、安装依赖包:
2、若git未安装的话,安装git:
3、安装git后,下载源码:
4、然后转到下载后node文件夹下,编译安装
5、然后测试代码:
编写如下小程序,命名为example.js,保存在node文件夹下。
6、然后Terminal下,执行:
7、浏览器地址栏:http://127.0.0.1:8030/
Ubuntu 11.10 安装Node.js的方法,需要的朋友可以参考下。
1、安装依赖包:
sudo apt-get install g++ curl libssl-dev apache2-utils2、若git未安装的话,安装git:
sudo apt-get install git3、安装git后,下载源码:
sudo git clone git://github.com/ry/node.git 4、然后转到下载后node文件夹下,编译安装
./configure
make
sudo make install 5、然后测试代码:
编写如下小程序,命名为example.js,保存在node文件夹下。
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World Node.js');
}).listen(8030, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8030/'); 6、然后Terminal下,执行:
node example.js7、浏览器地址栏:http://127.0.0.1:8030/
本文介绍在Ubuntu 11.10中安装Node.js的步骤,并通过一个简单的示例程序验证安装是否成功。
2022

被折叠的 条评论
为什么被折叠?



