centos6 nodejs 安裝測試

centos6:http://down.zhbit.com/downloads/system_iso/CentOS-6.0-i386-LiveCD.iso

安裝

挨個執行如下命令。
建立文件夾 mkdir /usr/local/node
cd /usr/local/node
wget http://nodejs.org/dist/v0.6.14/node-v0.6.14.tar.gz
tar zxvf node-v0.6.14.tar.gz
cd node-v0.6.14
./configure (這一步看看少什麼,新安裝的centos6 會少 gcc-c++ openssl,執行下面兩行命令安裝這些)
yum install gcc-c++
yum install openssl-devel
make(這個命令可能也須要先安裝:yum -y install gcc automake autoconf libtool make)
make install

測試
cd /usr/local/node/code
vim hello_node.js
輸入如下代碼:
var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('pairwinter');
}).listen(8088);
console.log('Server running at http://127.0.0.1:8088/');
運行:
node hello_node.js
訪問:
http://127.0.0.1:8088/
輸出:pairwinter
相關文章
相關標籤/搜索