• 돌아가기
  • 아래로
  • 위로
  • 목록
  • 댓글
Ubuntu

Ubuntu 20 Node.JS 환경 구축하기.

달소 달소 98

0

0

들어가며

이번에는 앞서 설치한 Ubuntu 20.04 LTS server 버전에 Node.JS를 사용하기 위한 환경 구축을 진행해보겠습니다.

Node.js 는 서버 측 프로그래밍을위한 JavaScript 런타임입니다. 개발자는 브라우저 기반 웹 개발에서 이미 익숙한 언어 인 JavaScript를 사용하여 확장 가능한 백엔드 기능을 만들 수 있습니다.

기본적으로 Node.JS는 apt 패키지로도 설치가 가능하지만 이 경우에는 구버전을 사용하기 때문에 최신버전으로 설치하는 과정으로 진행하겠습니다.

설치환경

Ubuntu 20.04 LTS Server

Nodesource PPA(개인아카이브) 등록하기

다른 버전의 Node.js를 설치하려면 NodeSource에서 유지 관리 하는 PPA (개인 패키지 아카이브)를 사용할 수 있습니다 . 이러한 PPA에는 공식 Ubuntu 리포지토리보다 더 많은 버전의 Node.js가 있습니다.

여기서는 최신버전인 15로 설치할 예정이며 이전버전을 설치하고싶으시면 앞에 숫자만 변경하시면 됩니다.

자세한 정보 : https://github.com/nodesource/distributions/blob/master/README.md

Node.js v15.x :

# Using Ubuntu 
curl -sL https://deb.nodesource.com/setup_15.x | sudo -E bash -

Node.js v14.x :

# Using Ubuntu 
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -

설치하기

설치는 매우 쉽습니다.
아래 명령어를 이용해주면 위에 등록한 레포지터리에서 최신버전의 node.js를 설치하게됩니다.

sudo apt-get install -y nodejs

설치후에 버전은 node -v 명령어로 확인이 가능합니다.

동작 테스트

이제 간단한 프로젝트하나를 생성해서 동작테스트를 진행하도록 하겠습니다.

먼저 테스트에 사용할 디렉터리 하나를 새로 만들어 줍니다.

mkdir -p /data/test/
vi /data/test/test.js

var http = require('http'); 
http.createServer(function (req, res) {
 res.writeHead(200, {'Content-Type': 'text/plain'});
 res.write('------------------------' + "\n");
 res.write('dalso node.js test!' + "\n");
 res.write('------------------------' + "\n");
 res.end();
 }).listen(7777);

이렇게 파일을 만들어줬으면 node로 실행시켜보겠습니다.
node /data/test/test.js &

동작 확인은 curl이나 웹으로 접근해보면 확인이 가능합니다.

신고공유스크랩
0

댓글 쓰기 권한이 없습니다. 로그인

취소 댓글 등록

신고

"님의 댓글"

이 댓글을 신고하시겠습니까?

댓글 삭제

"님의 댓글"

삭제하시겠습니까?


목록

공유

facebooktwitterpinterestbandkakao story

본 게시판은 서버구축 게시판과 통합되었습니다.

서버구축 게시판 이동하기
분류 제목 글쓴이 날짜 조회 추천
공지 서버OS(ESXi/Linux/Router 등) 게시판 이용안내. 달소 21.11.16.17:43 591 +1
ESXi 공지 ESXi 관련 추천글 모음 5 달소 21.04.23.12:19 3782 +6
ESXi USB LAN으로 ESXi8 설치하기.(Feat. Realtek LAN) 15 달소 23.01.01.18:51 2211 +2
Assistant OS 당신이 알아야할 새로운 스탠다드 Matter란 무엇인가 5 DarkAcid 22.12.30.02:38 747 +1
Proxmox 인텔 igpu는 gvt-g를 이용해 두개 이상의 가상머신에 패스스루 해줄 수 있네요. 13 니즛 22.12.23.02:19 1399 +1
Ubuntu
image
달소 22.08.01.22:56 8319 +4
Ubuntu
image
달소 22.04.01.17:29 5505 +5
Ubuntu
image
달소 22.04.01.15:34 5074 +3
Ubuntu
image
달소 22.04.04.17:28 4821 +3
Ubuntu
image
달소 22.04.22.11:46 2321 +3
Ubuntu
image
달소 22.09.05.17:26 2072 0
Ubuntu
image
레노 22.10.01.09:43 1752 +2
Ubuntu
image
달소 22.05.03.14:51 1681 +3
Ubuntu
image
달소 22.05.03.09:26 1655 0
Ubuntu
image
달소 21.02.26.15:02 1578 0
Ubuntu
image
달소 22.05.03.15:15 1237 +4
Ubuntu
image
달소 22.08.01.22:29 1099 0
Ubuntu
image
달소 22.03.30.21:30 1037 +1
Ubuntu
image
달소 22.05.12.12:00 926 +1
Ubuntu
image
달소 21.12.07.23:47 856 +1
Ubuntu
image
달소 22.04.01.14:58 852 +1
Ubuntu
image
달소 22.05.19.13:27 838 +2
Ubuntu
image
달소 21.03.22.23:48 760 0
Ubuntu
image
달소 21.04.22.11:37 741 0
Ubuntu
image
달소 22.08.21.15:03 670 0
Ubuntu
image
달소 22.12.16.11:00 642 0
Ubuntu
image
달소 21.03.22.22:59 620 +1
Ubuntu
image
달소 21.04.15.04:56 614 +2
Ubuntu
image
달소 22.04.28.18:44 613 +1
Ubuntu
normal
syaro 22.03.19.18:15 605 +1
Ubuntu
image
달소 21.03.26.16:55 595 +1
Ubuntu
image
달소 22.06.25.20:23 512 +2
Ubuntu
image
고양이 22.07.09.23:24 489 +3
Ubuntu
image
달소 21.01.19.14:53 392 0
Ubuntu
image
달소 21.03.19.23:31 377 0
Ubuntu
image
달소 21.04.22.17:11 332 +1
Ubuntu
image
달소 21.01.06.20:51 311 0
Ubuntu
image
달소 21.04.28.18:00 295 0
Ubuntu
image
달소 21.01.15.18:45 295 0
Ubuntu
image
달소 22.04.28.18:19 288 0
Ubuntu
image
달소 21.05.11.11:22 285 0
Ubuntu
image
달소 21.03.17.16:50 281 +1
Ubuntu
image
광기의초심자 21.11.20.22:27 271 +1
Ubuntu
image
달소 21.01.15.23:25 257 +1
Ubuntu
image
달소 21.04.22.14:28 242 0
Ubuntu
image
나스초보 22.06.14.17:20 221 0
Ubuntu
image
달소 21.01.06.15:18 218 +1
Ubuntu
image
달소 21.03.17.18:31 216 0
Ubuntu
image
달소 21.04.15.15:09 215 0
Ubuntu
image
달소 21.01.12.11:51 215 0
Ubuntu
image
달소 21.07.15.18:26 212 0
Ubuntu
image
달소 21.01.25.14:19 209 0
Ubuntu
image
달소 22.04.22.11:12 203 +3
Ubuntu
normal
만곰이 22.11.17.13:20 184 0
Ubuntu
image
달소 21.10.09.21:29 177 +1
Ubuntu
image
달소 21.01.11.18:21 161 +1
Ubuntu
image
달소 21.07.10.21:14 158 0
Ubuntu
image
달소 21.08.05.12:10 155 0
Ubuntu
image
달소 20.12.31.12:29 154 0
Ubuntu
image
달소 21.07.10.13:21 144 +1
Ubuntu
image
달소 21.03.19.18:34 144 0
Ubuntu
image
달소 21.01.07.16:13 138 0
Ubuntu
image
달소 21.01.19.22:52 130 +1
Ubuntu
normal
섭리 22.06.01.19:30 116 0
Ubuntu
image
달소 20.12.31.12:30 98 0
Ubuntu
normal
서버융 22.04.19.16:57 92 +1
Ubuntu
image
달소 22.04.01.11:35 84 +1
Ubuntu
image
달소 21.03.19.23:52 38 0