ouzhoudijie 发表于 2017-2-21 10:10:33

ubuntu11.10下安装Nodejs

  基本步骤如下
> wget http://nodejs.org/dist/node-v0.4.8.tar.gz
> tar -xvf node-v0.4.8.tar.gz
> cd node-v0.4.8
> ./configure (如果啥少了,就用aptitude安装缺少的东西)
> make
> sudo make install
  1 测试node是否安装成功
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″,虚拟机又没装X,否则虚拟机外就无法访问了
  console.log(‘Server running at http://127.0.0.1:8124/’);
  > node hello_node.js
  2 安装npm (nodeJS的类似rpm的软件)
> curl http://npmjs.org/install.sh | sh
  3. 安装express
> $ npm install -g express
  3.1 测试express是否安装成功
> express /tmp/foo && cd /tmp/foo
> npm install -d
> node app.js
  ubuntu下openssl找不到的问题:
  检查是否已安装openssl:
  sudo apt-get install openssl
  如果已安装执行以下操作:
sudo apt-get install libssl-dev
sudo apt-get install libssl0.9.8
页: [1]
查看完整版本: ubuntu11.10下安装Nodejs