您的位置:首页 > 运维架构 > Linux

centos install node.js

2012-03-31 16:58 337 查看
centos install node.js | 遨遊飛翔



centos install node.js

Posted on 八月 22, 2011 by shian

Sharenode.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
1
vim node.js
?View Code JAVASCRIPT
1
2
3
4
5
6
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 

執行node.js

http://127.0.0.1:8124/');[/code]

執行node.js

href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target=_blank>?View Code BASH
1
23
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已經正在運作中囉!

參考資料

http://nodejs.org/
http://howtonode.org/how-to-install-nodejs
您或許對這些文章有興趣:
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: