Server/CentOS

[CentOS 6.6] Node.js 설치하기

ezBuilder 2015. 4. 11. 00:42
반응형
NodeJS 의존 패키지 설치
su root
yum install gcc gcc-c++
yum install openssl-devel
yum install make

Node.js 다운로드 후 압축해제 및 디렉토리 이동(여기에서는 리눅스 64비트용을 다운받는다.)
cd /usr/local
mkdir server
cd ../src
wget http://nodejs.org/dist/v0.12.2/node-v0.12.2-linux-x64.tar.gz
tar zxvf node-v0.12.2-linux-x64.tar.gz
mv node-v0.12.2-linux-x64 ../server/node

profile을 수정하여 
Node.js PATH 설정하기
vi /etc/profile
export NODE_HOME=/usr/local/server/node
export PATH=$PATH:$NODE_HOME/bin

PATH 적용
source /etc/profile

root에서의 실행은 보안문제가 발생함으로 새로운 계정을 생성하여 실행한다.
useradd nodejs
passwd nodejs
su nodejs
NodeJS 테스트
node
console.log('test')
- 결과 -
test
undefined

모듈 설치하기
1. express : 웹 어플리케이션 프레임워크
2. forever : 어플리케이션이 예기치 못한 오류로 꺼지거나 하는 경우를 방지.
3. supervisor : 소스 수정시 자동반영.
4. socket.io : 웹소켓.

npm -g install forever supervisor express express-generator socket.io

종속성 모듈 설치
npm install -d



반응형