centos install node.js
node.js 已經火紅一段時間的東西了,簡單說node.js就是使用javascript來開發網站,就好像是php or asp這類的後端的程式語言。網路上可以找到很多相關的介紹,本篇將實做在centos安裝node.js並執行運作node.js。
安裝
? View Code BASH
1 2 3 4 5 6 wget http://nodejs.org/dist/node-v0.4.8.tar.gz tar -xvf node-v0.4.8.tar.gz cd /home/shian/node-v0.4.8 ./configure make make install安裝成功訊息
? View Code BASH
1 2 Waf: Leaving directory `/home/shian/node-v0.4.8/build' 'install' finished successfully (0.693s)建立node.js檔案
? View Code BASH
1vim node.js
? View Code JAVASCRIPT
1 2 3 4 5 6var 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:8124/');
執行node.js
? View Code BASH
1 2 3 node node.js Server running at http://127.0.0.1:8124/ http://127.0.0.1:8124最後在網頁上連結http://127.0.0.1:8124看到Hello Node.js,就表示node.js已經正在運作中囉!
參考資料
您或許對這些文章有興趣:
转载于:https://www.cnblogs.com/lexus/archive/2012/03/31/2427367.html