打开控制台,运行以下代码:
- git clone git://github.com/ry/node.git
- cd node
- ./configure
- make
- sudo make install
测试是否安装成功:
写一个Hello Node.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:8000/');
- > node hello_node.js
- Server running at http://127.0.0.1:8000/
如果安装成功访问 http://127.0.0.1:8000/ 是可以看到nodejs安装成功的界面。