본문 바로가기

개발관련/리눅스

우분투 10.04에서 node.js설치하기


패키지 매니저로 설치하기
이렇게

sudo apt-get install python-software-properties

sudo add-apt-repository ppa:chris-lea/node.js

sudo apt-get update

sudo apt-get install nodejs


또는 요렇게

sudo apt-get install nodejs-dev

 
소스를 받아서 컴파일
소스를 받아서 컴파일 해서 설치하고 싶은 사람은 아래를 보시길 

nodejs의 소스를 받아온다. 

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


 
/usr/local/에 압축을 풀고 심볼릭 링크를 걸어줌. 

$ mv node-v0.6.8.tar.gz /usr/local/ 
$ cd /usr/local
$ tar -xvzf node-v0.6.8.tar.gz 
$ ln -s node-v0.6.8 /usr/local/nodejs


 configure

$ cd /usr/local/nodejs/
$ ./configure 

 
요런 에러가 뜬다.

Checking for program g++ or c++       : not found

Checking for program icpc               : not found

Checking for program c++               : not found 

 
필요한 패키지를 설치해야함(y/n을 물으면 확인해보고 y해야 설치된다.)

$ sudo apt-get install build-essential

$ sudo apt-get install g++ curl libssl-dev apache2-utils

 
 다시 configure (물론 nodejs폴더로 이동해야함)

$ ./configure

 
성공하면 make 그리고 make install 

$ make && make install 


설치끝!

'install' finished successfully (0.389s)


설치완료!


위의 과정을 스크립트로 만들어놓은 링크가 있어 그곳의 스크립트를 남겨놓는다. 
http://apptob.org/

# Update System

echo 'System Update'

apt-get -y update

echo 'Update completed'

# Install help app

apt-get -y install libssl-dev git-core pkg-config build-essential curl gcc g++

# Download & Unpack Node.js - v. 0.6.8

echo 'Download Node.js - v. 0.6.8'

mkdir /tmp/node-install

cd /tmp/node-install

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

tar -zxf node-v0.6.8.tar.gz

echo 'Node.js download & unpack completed'

# Install Node.js

echo 'Install Node.js'

cd node-v0.6.8

./configure && make && checkinstall --install=yes --pkgname=nodejs --pkgversion "0.6.8" --default

echo 'Node.js install completed'



테스트해보자
아래는 nodejs홈페이지에 있는 예제소스 (example.js)로 저장

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


example.js실행해보기

$ node example.js


요딴식으로 나온다.

$ node example.js 

Server running at http://127.0.0.1:1337



헬로월드가 잘찍혀나오면 잘 설치된거임~~


'개발관련 > 리눅스' 카테고리의 다른 글

유저추가하기  (0) 2012.05.19
[리눅스 명령어] rm 정리  (0) 2012.03.02
[리눅스] 파일내 문자 검색  (0) 2011.04.27
리눅스에 톰캣설치하기  (0) 2010.07.21
CentOs 버추얼박스 게스트추가설치하기  (0) 2010.04.06