본문 바로가기
Web/자잘한거

centOs 7.x / Node js yum install

by juein 2018. 2. 26.

# Install Node.js 7.x repository (7.x 버전부터는 아래 추가)
curl -sL https://rpm.nodesource.com/setup_7.x | bash -


# Install Node.js and npm
yum install nodejs

yum install npm nodejs


#설치/버전 확인
node -v
npm -v

 


#웹서버 설치하여 페이지 확인

vi /home/basic.js

-------------------------------------------
var http = require('http');

var hostname = 'host이름 or ip 주소입력';
var port = 3000;

http.createServer(function(req, res){
res.writeHead(200, {
'Content-Type': 'text/plain'
});
res.end('Hello World\n');
}).listen(port, hostname);

console.log('Server running at http://'+hostname+':'+port);


#방화벽 포트허용
firewall-cmd --permanent --zone=public --add-port=3000/tcp
firewall-cmd --reload


#확인

==================================================


[express]

npm install -g express-generator

(express ejs로 프로젝트 생성)

express -e 디렉토리명(프로젝트명)

cd 디렉토리명
npm install
npm init

 

//js파일 수정할때마다
npm start

'Web > 자잘한거' 카테고리의 다른 글

파일시스템  (0) 2018.03.02
3 way hand shake  (0) 2018.03.02
OSI 7 계층  (0) 2018.03.02
TCP/IP  (0) 2018.03.02
CentOs 7.1v / APM(php 7) install  (0) 2018.02.26

댓글