安裝步驟如下

1.安裝必要的套件,才能繼續安裝

# apt-get install gcc g++ 
# apt-get install make
# apt-get install git

2.使用git安裝nodejs

# git clone https://github.com/joyent/node.git

3.列出所有版本,並使用git checkout 選擇所需要的版本

# cd node
# git tag
# git checkout v0.10.36

4.開始安裝

# ./configure
# make
# make install

5.驗證安裝是否成功

# node -v
v0.10.36

# npm -v
1.4.28

6.建立一個web.js,內容如下

var http = require('http');
http.createServer(function (req, res){
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n);
}).listen(8080, '0.0.0.0');

console.log('Server running at http://0.0.0.0:8080/');

7. 啟動web.js,並確認結果

# node web.js
Server running at http://0.0.0.0:8080/

使用browser看 http://你的主機IP:8080
如果成功就能看到

Hello World

完成

arrow
arrow
    全站熱搜

    痞客興 發表在 痞客邦 留言(0) 人氣()