ubuntu nodejs 安装



sudo apt-get update  
sudo apt-get install -y python-software-properties python g++ make  
sudo add-apt-repository ppa:chris-lea/node.js  
sudo apt-get update  
sudo apt-get install nodejs  

注意:从 Node.js v0.10.0 开始,Chris Lea 仓库中提供的 Node.js 安装包默认包含了 npm 和 nodejs-dev

sudo add-apt-repository ppa:chris-lea/node.js 这条指令时,系统会出现如下提示,询问你是否确定要添加上面的 PPA:
不用理会,直接按回车键就 OK!


确认是否安装成功

node -v

返回信息  v0.10.37


npm -v

返回信息 1.4.28


ok goodluck




hello.js

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});

  res.end('Hello DemonZhang');
}).listen(8716, "127.0.0.1"); //端口  IP  根据自己服务来设置


进入服务器 node hello.js

然后 网页上打开 这个链接  http://127.0.0.1:8716/

ok

猜你喜欢

转载自laoyaos.iteye.com/blog/2197515