node.js 初探 - 安裝配置

 

     之因此開始學習node.js,是由於我在學習html5的期間,遇到了websocket這個技術 。websocket的服務端能夠用python,php和node.js寫,python沒學過,php不熟,最終選擇了node.js,由於它是服務器端的javascript。同是js,就減小了學習的成本。javascript

    

  
  
           
  
  
  1. [root@localhost pkgs]# wget http://nodejs.org/dist/node-v0.6.4.tar.gz 

網速慢,等等吧。。。。。。。。。。。。。。。。。。。。php

 

  
  
           
  
  
  1. [root@localhost build]# tar zxvf  ../pkgs/node-v0.6.4.tar.gz 
  2.   [root@localhost build]# ./configure --prefix=/usr/local/node
  3. [root@localhost build]# make && make install 

編譯安裝時間也比較長,等。。。。。。。。。。。。。。。html

安裝好以後進行測試 :html5

 

  
  
           
  
  
  1. var http  = require('http'); 
  2.  
  3. http.createServer(function(req,res){ 
  4.         res.writeHead(200,{'Context-Type':'text/plain'}); 
  5.         res.end('Hello ,my node.js\n'); 
  6.  
  7. }).listen(8888,"127.0.0.1"); 

 

  
  
           
  
  
  1. [root@localhost nodeJS]# /usr/local/node/bin/node test.js  

 

 

 

能夠看到已經訪問成功了。java

OK。安裝測試學到這裏了。下一篇繼續學習。node

相關文章
相關標籤/搜索