node.js

來源:互聯網
上載者:User

標籤:blog   http   io   ar   os   sp   檔案   on   log   

1、在根目錄下建立一個目錄 /down,用來儲存下載的檔案

# mkdir /down

cd /down

2、安裝 node.js 相關軟體

首先要安裝 gcc gcc-g++ openssl-devel  

# yum install gcc gcc-g++ openssl-devel

yum install -y bzip2*

 

3、下載 python 2.7

#wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz

解壓安裝

#tar zxvf Python-2.7.3.tgz

#cd Python-2.7.3

#./configure && make && make install

 

重起查看版本:python –V  為2.7.3後

4、下載 node.js 解壓 安裝

# cd /down

# wget http://nodejs.org/dist/v0.8.14/node-v0.8.14.tar.gz

# tar zxvf node-v0.8.14.tar.gz

# cd node-v0.8.14

# ./configure && make && make install

這裡可能需要幾分鐘時間

最終看到  updating shebang of /usr/local/bin/npm to /usr/local/bin/node

就說明安裝成功了

為了驗證安裝是否成功可以驗證一下: 

寫一段指令碼 放到 /down 目錄下,檔案命名為 node.js

 

var http = require(‘http‘);

http.createServer(function(req,res){

res.end(‘hello node.js‘);

}).listen(8080,"127.0.0.1");

console.log(‘Server is running at http://127.0.0.1:8080/‘)

然後用命令列啟動

#node /down/node.js 

看到 命令列輸出 

?

1

Server is running at http://127.0.0.1:8080/

然後用 centos 內建的 firefox 開啟 http://127.0.0.1:8080/

ok 至此結束 o(∩_∩)o 哈哈

node.js

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.