CentOS에 Node.JS 설치하기
프로그래밍 2014. 5. 15. 10:22
설치
1 2 3 4 5 6 7 8 9 | $ 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
1 2 3 4 5 6 7 8 | 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); |
서버 가동
1 2 | $ . /node test .js Server running at http: //localhost :8080/ |
방화벽 오픈
1 2 3 | $ iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT $ service iptables save $ service iptables restart |
테스트 방법
웹브라우져로 연결하여, Hello World 문구가 뜨면 성공