aws에 Django 프로젝트를 배포한 과정을 기록합니다.
<로컬 콘솔>
현재의 작업환경(가상환경)에 설치되어 있는 패키지의 리스트를 모두 출력해줌 : pip freeze >> requirements.txt
<서버 콘솔>
sudo apt update
sudo apt-get install build-essential
sudo apt-get python3
sudo apt-get install python3-pip
github clone을 위한 deploy key 생성 :
ssh-keygen -t rsa -> Enter file in which to save the key 그냥 엔터 -> enter passphrase 비번 입력
-> ~/.ssh 밑에 id_rsa.pub 파일 생김 -> cat id_rsa.pub -> 복사 -> github clone할 resposetory -> settings -> deploy keys -> add deploy key -> 복사값 입력 > 서버에서 push도 허용할 경우는 allow write access 체크
github 계정에 등록할 public key 생성:
ssh-keygen -t rsa -C "git hub이메일" -> Enter file in which to save the key 그냥 엔터 -> enter passphrase 비번 입력
-> ~/.ssh 밑에 id_rsa.pub 파일 생김 -> cat id_rsa.pub -> 복사 -> github 계정 -> settings -> SSH and GPG keys -> new ssh key -> 퍼블릭 key 값 붙여넣기
서버에서 git repository를 git clone
가상환경을 사용하여 배포하기:
sudo apt-get install virtualenv
virtualenv -p python myenv
requirements 다운:
pip install -r requirements.txt
mysqlclient 설치 에러 해결 :
sudo apt-get install libmysqlclient-dev
<서버 콘솔>
ssh console 접속이 끊어져도 서버 계속 돌리기