代码改变世界

Ubuntu9.10 安装node.js

2012-02-21 22:51  Lecone.JY.HU  阅读(243)  评论(0编辑  收藏  举报

1.安装依赖包

sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core

在操作过程中出现无法找到libssl-dev 包。

解决办法

获取root权限,忘记了密码,修改root密码 

sudo passwd root

输入新密码。 

su -
apt-get -f install

 若有无法安装libssl则,无错误跳过。

  wget http://launchpadlibrarian.net/60293933/libssl-dev_0.9.8g-16ubuntu3.5_i386.deb
 sudo dpkg -i libssl-dev_0.9.8g-16ubuntu3.5_i386.deb

安装node.js

git clone git://github.com/joyent/node.git
cd node
./configure
make
sudo make install

 验证:

在任一路径下建文件hello.js

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

在终端中输入

node hello.js

终端显示为

Server running at http://127.0.0.1:8124/

则生成成功可以在浏览器中输入地址http://127.0.0.1:8124/

的风格风格