React로 제작한 Portfolio를 배포(?) 하기 위하여 무료 Amazon Elastic Compute Cloud를 이용해보려고 한다.
1. Mobaxtem 사용하여 SSH와 SFTP를 연결한다
참고로 )
SSH란 Secure Shell의 약자로 네트워크 상 다른 컴퓨터에 접속 및 명령을 실행하거나 파일을 복사 할 수 있는 프로그램이다. ( Secure Shell에서 알 수 있듯이 보안이 매우 중요한 요소이다. ) 우리는 ec2 ubuntu server에 접속하기 위해 인증키를 ( .pem )를 발급받고 이를 통해 ubuntu 서버에 접속하여 우리가 서버에 프로젝트를 올리고 명령을 실행시킨다.
2. Node module file을 제외한 프로젝트 file들을 .tar로 압축한 후 sftp화면에서 압축파일을 원하는 directory에 올린다.
-> .tar로 압축방법 : window cmd 창에서 경로를 맞게 변경 후 tar -cvf (압축 파일명).tar (압축할 폴더 또는 파일) 명령 입력
3. SSH에 들어와 sudo su - 명령어를 입력 후 root권한으로 파일에 접근한다
( su: user //root does not exist or the user entry does not contain all the required fields 와 같은 문구로 erro가 났을 때는 sudo su - 라는 명령어를 쳐 root를 추가해준다 )
4. SSH에서 명령어 tar -xvf (압축파일명).tar 입력하여 tar파일 압축풀기
5. 압축을 푼 파일들을 통해 package를 깔아야 한다.
- 5-1 apt-get update 를 통행 file을 update 해주자
- 5-2 apt-get install nodejs // nodejs 설치 -> 설치할때 ( home / ubuntu / 경로에서 nodejs 를 깔자 -> npm도 같이 깔림 ! )
- 5-4 npm install // package 설치 ( apt-get upgrade // 설치된 패키지들 모두 새버전으로 업데이트 )
6. Package 를 모두 깔았다면 프로젝트를 실행해보자
리액트의 경우 브라우저 주소창에 탄력적ip/3000 을 통해 접속할 수 있다.
※ SSH 명령어
1. 포트로 서버 접속 끊기
fuser -k 3000/tcp
fuser - k 8080/tcp
2. 폴더삭제
rm -r 폴더명/
3. 설치된 node 삭제
$sudo apt-get --purge remove node
$sudo apt-get --purge remove nodejs
참조 ↓
https://leejungyeoul.tistory.com/86?category=649936