搜尋此網誌

2015年4月27日 星期一

Installing Node.js via package manager

Source:
http://www.unixmen.com/install-node-js-centos-7/

epel’s repo 要事先安排好,如果沒有可以參照以下:
wget -r --no-parent -A 'epel-release-*.rpm' http://dl.fedoraproject.org/pub/epel/7/x86_64/e/

rpm -hiv epel-release-7-5.noarch.rpm
會在 /etc/yum.repos.d 底下建立兩個 epel’s repo 檔案  



yum -y install npm

yum -y install nodejs

安裝好 nodejs 之後
編輯一個文字檔,進行測試

vi hello.js

var http = require('http');
http.createServer(function (request, response) {
 response.writeHead(200, {'Content-Type': 'text/plain'});
 response.end('Hello World\n');
 }).listen(8080);

console.log('Server started');
存檔

執行
node hello.js

打開瀏覽器
http://127.0.0.1:8080
看到 Hello World 即可。

node -v 確認版本



另一種安裝方法:

wget http://nodejs.org/dist/v0.10.30/node-v0.10.30-linux-x64.tar.gz

tar xzvf node-v* && cd node-v*

sudo yum install gcc gcc-c++

./configure
make

node --version 確認版本

沒有留言:

張貼留言

搜尋此網誌