Deploy with AWS EC2

Seonmi Choi·2021년 11월 3일
0

Start again!!!

목록 보기
32/40

여기서 부터 시작!!!

헷갈리고 힘들었던 부분

 chmod 400 ~Downloads/Withyou_Project.pem
zsh: no such user or named directory: Downloads

경로 지정을 잘 해줘야 한다.

 chmod 400 ~/Downloads/withyou_new_project.pem

오류없이 해결이 되었다. keychain 접근이 잘 안되서 그러는 줄 알고 keychain에 관련된 오류들을 폭풍 검색했으나 keychain 리셋만 한거 같다.

 ssh -i "withyou_new_project.pem" ubuntu@ec2-52-79-251-237.ap-northeast-2.compute.amazonaws.com
 
Warning: Identity file withyou_new_project.pem not accessible: No such file or directory.
The authenticity of host 'ec2-52-79-251-237.ap-northeast-2.compute.amazonaws.com (52.79.251.237)' can't be established.
ECDSA key fingerprint is SHA256:8+E8wob/YMJGTrD0JJqUeZZMU2j2EXzTpsjb8RfYI0M.
Are you sure you want to continue connecting (yes/no/[fingerprint])?

여기서도 어이 없는 실수!!! 파일 경로 설정을 제대로 해주지 않았다. 결론은 그것이었다.ㅡㅜ

ssh -i ~/Downloads/withyou_new_project.pem ubuntu@ec2-52-79-251-237.ap-northeast-2.compute.amazonaws.com

패키지 매니저가 관리하는 패키지의 정보를 최신 상태로 업데이트하기 위해서 아래 명령어를 사용

sudo apt update
sudo apt install npm

EC2 우분트 가상 서버 설치
이제 nvm 설치
NVM GitHub 페이지의 Install & Update Script 부분을 참조하여 진행

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

or

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

nvm 실행 명령 : This loads nvm

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"

위의 코드를 입력하지 않으면 아래의 에러가 뜬다.

 ~ nvm --version
zsh: command not found: nvm

nvm 확인

nvm --version
0.39.0

node 설치

nvm install node 

node.js의 설치가 끝나면 npm 명령어가 정상적으로 입력되지 않는 상황을 방지하기 위해서 터미널에

sudo apt install npm

명령어를 입력해서 npm 설치를 진행. 위 과정이 모두 끝나면 node.js 기반 서버를 실행하는 데 필요한 개발 환경 구축이 완료

git을 통해 서버 코드 클론 받기!!!
깃헙 아이디와 비번 입력
이번은 깃헙의 토큰을 입력해야 한다

npm install
npm start

서버 실행!!!

> server@0.0.0 start
> nodemon ./bin/www

[nodemon] 2.0.14
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node ./bin/www`
여기는 4000

'보안 그룹' 설정을 하지 않으면 브라우저에 오류메시지가 뜬다
보안그룹:인스턴스로 들어가고 인스턴스에서 나가는 트래픽에 대한 가상 방화벽

인바운드: 인스턴스로 들어가는 트래픽
인바운드규칙: EC2 인스턴스로 들어오는 트래픽에 대한 규칙
인바운드 규칙에 허용되지 않은 규칙은 인스턴스로 접근하지 못하도록 필터링
EC2 인스턴스를 생성하면 기본적으로 SSH 접속을 위한 SSH 규칙만 생성되어있음

아웃바운드: 인스턴스에서 나가는 트래픽
아웃바운드 규칙: EC2 인스턴스에서 나가는 트래픽에 대한 규칙
EC2 인스턴스를 생성하면 기본적으로 나가는 모든 트래픽을 허용

profile
I am not afraid of learning!

0개의 댓글