CentOS에 Node.JS 설치하기

설치

$ cd /usr/share $ wget http://nodejs.org/dist/v0.10.28/node-v0.10.28-linux-x64.tar.gz $ tar xvzf node-v0.10.28-linux-x64.tar.gz // Node.JS 버전 출력으로 설치확인 $ cd node-v0.10.28-linux-x64/bin $ ./node -v v0.10.28

$ vi test.js

var http = require('http'); var callbackFunction = function(req, res){ res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }; http.createServer(callbackFunction).listen(8080); console.log('Server running at http://localhost:8080/');

서버 가동

$ ./node test.js Server running at http://localhost:8080/

방화벽 오픈

$ iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT $ service iptables save $ service iptables restart

테스트 방법

웹브라우져로 연결하여, Hello World 문구가 뜨면 성공