📢 공지사항
home

Ubuntu 배포하기

번호
29
비고
35:47
주차
5월 넷째주
확인
1.
EC2 인스턴스(가상 서버) 만들기
우측 상단 서울 확인
EC2 검색
Instances → Launch Instances 인스턴스 시작
Ubuntu Server 20.04 LTS (64-bit x86)
t2.micro (Free tier eligible)
다음: 인스턴스 세부 정보 구성(Add storage) ... 넘어감 스토리지 추가
Storage 설정
8~30 중 선택(프리티어는 30까지 무료)
다음 ... tag 넘어감 보안 그룹 구성
Security Group 이름 지음 nostalgia-likelionproject
→ Add Rule 규칙 추가
HTTP
HTTPS
Custom(사용자 지정) → TCP → 8000(포트범위) → 0.0.0.0/0, ::/0
Review and Launch(검토 및 시작) → Launch(시작하기)
ssh 키 페어 ... 서버 들어가기 위한 자물쇠 열쇠
create a new key pair(새 키 페어 생성)
이름은 원하는 이름 ... lion
Download Key Pair ... .pem 파일 다운로드
⇒ 해당 파일 있어야 서버에 접속 가능! 절대 지우지 x
** aws 프리티어? 는 사용기간 1년 ... 1년 지나면 요금 청구 ,,, 강의 끝나면 인스턴스 삭제 **
2.
Elastic IP 받기
다음 인스턴스 시작이 개시됨: i-0c9f319eb2d638696
i 뭐시기 누르면 팬딩(pending)중인 인스턴스 볼 수 o
서버 생성 중에 할거!
Instance ID i-0c9f319eb2d638696 복사해서 Elastic IPs(탄력적 IP...ㅋ) 로 감
ALLOCATE ELASTIC IP(탄력적 IP 주소 할당) ... 새로운 IP 받아올 수 있음
→ 서버를 껐다 킬 때마다 바뀌는 IP ... IP 한번 받아두면 삭제 전까지 사용 가능
Allocate(할당)
IP 주소 누르고 Associate Elastic IP Adress(탄력적 IP 주소 연결) 버튼 누름
아까 복사한 i-0c9f319eb2d638696 넣음
Associate(연결)
3.
SSH 연결하기
인스턴스로 돌아가서
새로 만든 IP 주소 복사 3.37.107.165
cmd 창 열어서 ssh ubuntu@3.37.107.165 -i C:\Users\조여정\Downloads\lion.pem
다운로드한 파일 갖다 붙여도 C: ~ 뜸
ssh 서버 접속
ubuntu 아이디
왜... 자동 로그인...?
서버 접속 주소
ssh ubuntu@아까 받은 Elastic IP -i 다운받은 pem 파일
yes/no 물으면 yes
4.
필요한 패키지 설치
sudo apt update && sudo apt -y upgrade
sudo apt install -y python3 python3-pip python3-dev python3-venv build-essential libpq-dev vim git
sudo reboot → 업그레이드 도중 일부 시스템 파일 변경되므로 재부팅 추천(3분 정도 접속x)
sudo : 관리자 권한으로 실행해라
5.
패키지 설치 동안 settings.py 수정
환경 변수 적용(앞에서 한건디?)
DEBUG = (os.environ.get('DEBUG', 'True') != 'False')
ALLOWED_HOSTS = ['*']
... 왜 별도의 bash 창 에서 code . 으로 vscode 실행하는거..?
pip freeze > requirement.txt
git add -A
git commit -m "edit for deploy" (deployment?)
git push

오류

fatal: The current branch main has no upstream branch.
git remote add orign git주소
git remote --v

git add --force project2/

6.
cmd 창에
python3 -m venv venv
git clone 내깃허브레포지토리 django-app
cd django-app
source ../venv/bin/activate
⇒ 위에 ssh 부터 다시 해봐
안됨....
pip install virtualenv
virtualenv venv
call venv/scripts/activate
→ cd project2 로 이동해보자
pip install -r requirements.txt
python manage.py runserver 주소:8000
3.37.107.165
⇒ 안됨
(venv) C:\Users\조여정\django-app\project2>python manage.py runserver 3.37.107.165:8000 Watching for file changes with StatReloader Performing system checks...
Python
복사
System check identified no issues (0 silenced).
Python
복사
You have 20 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): account, admin, auth, blog, contenttypes, sessions. Run 'python manage.py migrate' to apply them. May 29, 2021 - 16:25:42 Django version 3.2.3, using settings 'project2.settings' Starting development server at http://3.37.107.165:8000/ Quit the server with CTRL-BREAK. Error: That IP address can't be assigned to.
Python
복사
(venv) C:\Users\조여정\django-app\project2>python manage.py migrate
Python
복사
Watching for file changes with StatReloader Performing system checks...
Python
복사
System check identified no issues (0 silenced). May 29, 2021 - 16:27:12 Django version 3.2.3, using settings 'project2.settings' Starting development server at http://3.37.107.165:8000/ Quit the server with CTRL-BREAK. Error: That IP address can't be assigned to.
Python
복사
(venv) C:\Users\조여정\django-app\project2>python manage.py runserver 3.37.107.165:8000 Watching for file changes with StatReloader Performing system checks...
Python
복사
System check identified no issues (0 silenced). May 29, 2021 - 16:35:20 Django version 3.2.3, using settings 'project2.settings' Starting development server at http://3.37.107.165:8000/ Quit the server with CTRL-BREAK. Error: That IP address can't be assigned to.
Python
복사
(venv) C:\Users\조여정\django-app\project2>python manage.py runserver Watching for file changes with StatReloader Performing system checks...
Python
복사
System check identified no issues (0 silenced). May 29, 2021 - 16:35:30 Django version 3.2.3, using settings 'project2.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK.
Python
복사
나는 노력했으나 포기 각인가
Microsoft Windows [Version 10.0.19042.985] (c) Microsoft Corporation. All rights reserved. C:\Users\조여정>ssh ubuntu@3.37.107.165 -i "C:\Users\조여정\Desktop\2021\대외 활동\제 9기 멋쟁이사자처럼\3. Django\lion.pem" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions for 'C:\\Users\\\354\241\260\354\227\254\354\240\225\\Desktop\\2021\\\353\214\200\354\231\270 \355\231\234\353\217\231\\\354\240\234 9\352\270\260 \353\251\213\354\237\201\354\235\264\354\202\254\354\236\220\354\262\230\353\237\274\\3. Django\\lion.pem' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored. Load key "C:\\Users\\\354\241\260\354\227\254\354\240\225\\Desktop\\2021\\\353\214\200\354\231\270 \355\231\234\353\217\231\\\354\240\234 9\352\270\260 \353\251\213\354\237\201\354\235\264\354\202\254\354\236\220\354\262\230\353\237\274\\3. Django\\lion.pem": bad permissions ubuntu@3.37.107.165: Permission denied (publickey). C:\Users\조여정>ssh ubuntu@3.37.107.165 -i C:\Users\조여정\Downloads\lion.pem Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-1048-aws x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of Sat May 29 08:06:02 UTC 2021 System load: 0.0 Processes: 103 Usage of /: 26.1% of 7.69GB Users logged in: 0 Memory usage: 21% IPv4 address for eth0: 172.31.34.243 Swap usage: 0% * Super-optimized for small spaces - read how we shrank the memory footprint of MicroK8s to make it the smallest full K8s around. https://ubuntu.com/blog/microk8s-memory-optimisation Last login: Sat May 29 07:54:21 2021 from 39.127.68.135 ubuntu@ip-172-31-34-243:~$ sudo apt update && sudo apt -y upgrade Hit:1 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal InRelease Hit:2 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal-updates InRelease Hit:3 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal-backports InRelease Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease Reading package lists... Done Building dependency tree Reading state information... Done All packages are up to date. Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. ubuntu@ip-172-31-34-243:~$ sudo apt install -y python3 python3-pip python3-dev python3-venv build-essential libpq-dev vim git Reading package lists... Done Building dependency tree Reading state information... Done python3 is already the newest version (3.8.2-0ubuntu2). python3-dev is already the newest version (3.8.2-0ubuntu2). vim is already the newest version (2:8.1.2269-1ubuntu5). python3-venv is already the newest version (3.8.2-0ubuntu2). build-essential is already the newest version (12.8ubuntu1.1). git is already the newest version (1:2.25.1-1ubuntu3.1). libpq-dev is already the newest version (12.6-0ubuntu0.20.04.1). python3-pip is already the newest version (20.0.2-5ubuntu1.5). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. ubuntu@ip-172-31-34-243:~$ sudo reboot ubuntu@ip-172-31-34-243:~$ Connection to 3.37.107.165 closed by remote host. Connection to 3.37.107.165 closed. C:\Users\조여정>python3 -m venv venv C:\Users\조여정>git clone https://github.com/NostalgiaJ/likelion django-app fatal: destination path 'django-app' already exists and is not an empty directory. C:\Users\조여정>cd django-app C:\Users\조여정\django-app>source ../venv/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. C:\Users\조여정\django-app>pip install virtualenv Requirement already satisfied: virtualenv in c:\users\조여정\appdata\local\programs\python\python39\lib\site-packages (20.4.7) Requirement already satisfied: distlib<1,>=0.3.1 in c:\users\조여정\appdata\local\programs\python\python39\lib\site-packages (from virtualenv) (0.3.1) Requirement already satisfied: appdirs<2,>=1.4.3 in c:\users\조여정\appdata\local\programs\python\python39\lib\site-packages (from virtualenv) (1.4.4) Requirement already satisfied: six<2,>=1.9.0 in c:\users\조여정\appdata\local\programs\python\python39\lib\site-packages (from virtualenv) (1.16.0) Requirement already satisfied: filelock<4,>=3.0.0 in c:\users\조여정\appdata\local\programs\python\python39\lib\site-packages (from virtualenv) (3.0.12) WARNING: You are using pip version 20.2.3; however, version 21.1.2 is available. You should consider upgrading via the 'c:\users\조여정\appdata\local\programs\python\python39\python.exe -m pip install --upgrade pip' command. C:\Users\조여정\django-app>virtualenv venv created virtual environment CPython3.9.2.final.0-64 in 1564ms creator CPython3Windows(dest=C:\Users\조여정\django-app\venv, clear=False, no_vcs_ignore=False, global=False) seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\조여정\AppData\Local\pypa\virtualenv) added seed packages: Django==3.2.3, Pillow==8.2.0, asgiref==3.3.4, boto3==1.17.83, botocore==1.20.83, dj_database_url==0.5.0, django_storages==1.11.1, gunicorn==20.1.0, jmespath==0.10.0, pip==21.1.2, psycopg2_binary==2.8.6, python_dateutil==2.8.1, pytz==2021.1, s3transfer==0.4.2, setuptools==57.0.0, six==1.16.0, sqlparse==0.4.1, urllib3==1.26.5, wheel==0.36.2, whitenoise==5.2.0 activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator C:\Users\조여정\django-app>python -m pip install --upgrade pip Collecting pip Using cached pip-21.1.2-py3-none-any.whl (1.5 MB) Installing collected packages: pip Attempting uninstall: pip Found existing installation: pip 20.2.3 Uninstalling pip-20.2.3: Successfully uninstalled pip-20.2.3 Successfully installed pip-21.1.2 C:\Users\조여정\django-app>python -m pip install --upgrade pip Requirement already satisfied: pip in c:\users\조여정\appdata\local\programs\python\python39\lib\site-packages (21.1.2) C:\Users\조여정\django-app>pip install virtualenv Requirement already satisfied: virtualenv in c:\users\조여정\appdata\local\programs\python\python39\lib\site-packages (20.4.7) Requirement already satisfied: filelock<4,>=3.0.0 in c:\users\조여정\appdata\local\programs\python\python39\lib\site-packages (from virtualenv) (3.0.12) Requirement already satisfied: six<2,>=1.9.0 in c:\users\조여정\appdata\local\programs\python\python39\lib\site-packages (from virtualenv) (1.16.0) Requirement already satisfied: distlib<1,>=0.3.1 in c:\users\조여정\appdata\local\programs\python\python39\lib\site-packages (from virtualenv) (0.3.1) Requirement already satisfied: appdirs<2,>=1.4.3 in c:\users\조여정\appdata\local\programs\python\python39\lib\site-packages (from virtualenv) (1.4.4) C:\Users\조여정\django-app>virtualenv venv created virtual environment CPython3.9.2.final.0-64 in 1082ms creator CPython3Windows(dest=C:\Users\조여정\django-app\venv, clear=False, no_vcs_ignore=False, global=False) seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\조여정\AppData\Local\pypa\virtualenv) added seed packages: Django==3.2.3, Pillow==8.2.0, asgiref==3.3.4, boto3==1.17.83, botocore==1.20.83, dj_database_url==0.5.0, django_storages==1.11.1, gunicorn==20.1.0, jmespath==0.10.0, pip==21.1.2, psycopg2_binary==2.8.6, python_dateutil==2.8.1, pytz==2021.1, s3transfer==0.4.2, setuptools==57.0.0, six==1.16.0, sqlparse==0.4.1, urllib3==1.26.5, wheel==0.36.2, whitenoise==5.2.0 activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator C:\Users\조여정\django-app>call venv/scripts/activate (venv) C:\Users\조여정\django-app>cd project2 (venv) C:\Users\조여정\django-app\project2>pip install -r requirements.txt Requirement already satisfied: asgiref==3.3.4 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 1)) (3.3.4) Requirement already satisfied: boto3==1.17.83 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 2)) (1.17.83) Requirement already satisfied: botocore==1.20.83 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 3)) (1.20.83) Requirement already satisfied: dj-database-url==0.5.0 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 4)) (0.5.0) Requirement already satisfied: Django==3.2.3 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 5)) (3.2.3) Requirement already satisfied: django-storages==1.11.1 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 6)) (1.11.1) Requirement already satisfied: gunicorn==20.1.0 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 7)) (20.1.0) Requirement already satisfied: jmespath==0.10.0 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 8)) (0.10.0) Requirement already satisfied: Pillow==8.2.0 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 9)) (8.2.0) Requirement already satisfied: psycopg2-binary==2.8.6 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 10)) (2.8.6) Requirement already satisfied: python-dateutil==2.8.1 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 11)) (2.8.1) Requirement already satisfied: pytz==2021.1 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 12)) (2021.1) Requirement already satisfied: s3transfer==0.4.2 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 13)) (0.4.2) Requirement already satisfied: six==1.16.0 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 14)) (1.16.0) Requirement already satisfied: sqlparse==0.4.1 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 15)) (0.4.1) Requirement already satisfied: urllib3==1.26.5 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 16)) (1.26.5) Requirement already satisfied: whitenoise==5.2.0 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 17)) (5.2.0) Requirement already satisfied: setuptools>=3.0 in c:\users\조여정\django-app\venv\lib\site-packages (from gunicorn==20.1.0->-r requirements.txt (line 7)) (57.0.0) (venv) C:\Users\조여정\django-app\project2>python manage.py runserver 3.37.107.165:8000 Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). May 29, 2021 - 17:13:03 Django version 3.2.3, using settings 'project2.settings' Starting development server at http://3.37.107.165:8000/ Quit the server with CTRL-BREAK. Error: That IP address can't be assigned to. (venv) C:\Users\조여정\django-app\project2>python manage.py runserver 3.37.107.165 CommandError: "3.37.107.165" is not a valid port number or address:port pair. (venv) C:\Users\조여정\django-app\project2>python manage.py runserver 0:8000 Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). May 29, 2021 - 17:18:04 Django version 3.2.3, using settings 'project2.settings' Starting development server at http://0:8000/ Quit the server with CTRL-BREAK. Error: [Errno 11001] getaddrinfo failed (venv) C:\Users\조여정\django-app\project2>sudo gedit /etc/network/interfaces 'sudo' is not recognized as an internal or external command, operable program or batch file. (venv) C:\Users\조여정\django-app\project2>auto lo 'auto' is not recognized as an internal or external command, operable program or batch file. (venv) C:\Users\조여정\django-app\project2>python manage.py runserver 3.37.107.165:8000 Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). May 29, 2021 - 17:24:40 Django version 3.2.3, using settings 'project2.settings' Starting development server at http://3.37.107.165:8000/ Quit the server with CTRL-BREAK. Error: That IP address can't be assigned to. (venv) C:\Users\조여정\django-app\project2>python manage.py runserver Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). May 29, 2021 - 17:27:30 Django version 3.2.3, using settings 'project2.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK. C:\Users\조여정\django-app\project2\blog\views.py:17: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: <class 'blog.models.Blog'> QuerySet. paginator = Paginator(blogs, 3) [29/May/2021 17:30:12] "GET / HTTP/1.1" 200 3674 [29/May/2021 17:30:12] "GET /static/squirrel.png HTTP/1.1" 200 385087 (venv) C:\Users\조여정\django-app\project2>python manage.py runserver 3.37.107.165 CommandError: "3.37.107.165" is not a valid port number or address:port pair. (venv) C:\Users\조여정\django-app\project2>python manage.py runserver 3.37.107.165:8000 Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). May 29, 2021 - 17:31:03 Django version 3.2.3, using settings 'project2.settings' Starting development server at http://3.37.107.165:8000/ Quit the server with CTRL-BREAK. Error: That IP address can't be assigned to. (venv) C:\Users\조여정\django-app\project2>pip install -r requirements.txt Requirement already satisfied: asgiref==3.3.4 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 1)) (3.3.4) Requirement already satisfied: boto3==1.17.83 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 2)) (1.17.83) Requirement already satisfied: botocore==1.20.83 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 3)) (1.20.83) Requirement already satisfied: dj-database-url==0.5.0 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 4)) (0.5.0) Requirement already satisfied: Django==3.2.3 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 5)) (3.2.3) Requirement already satisfied: django-storages==1.11.1 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 6)) (1.11.1) Requirement already satisfied: gunicorn==20.1.0 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 7)) (20.1.0) Requirement already satisfied: jmespath==0.10.0 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 8)) (0.10.0) Requirement already satisfied: Pillow==8.2.0 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 9)) (8.2.0) Requirement already satisfied: psycopg2-binary==2.8.6 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 10)) (2.8.6) Requirement already satisfied: python-dateutil==2.8.1 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 11)) (2.8.1) Requirement already satisfied: pytz==2021.1 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 12)) (2021.1) Requirement already satisfied: s3transfer==0.4.2 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 13)) (0.4.2) Requirement already satisfied: six==1.16.0 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 14)) (1.16.0) Requirement already satisfied: sqlparse==0.4.1 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 15)) (0.4.1) Requirement already satisfied: urllib3==1.26.5 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 16)) (1.26.5) Requirement already satisfied: whitenoise==5.2.0 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 17)) (5.2.0) Requirement already satisfied: setuptools>=3.0 in c:\users\조여정\django-app\venv\lib\site-packages (from gunicorn==20.1.0->-r requirements.txt (line 7)) (57.0.0) (venv) C:\Users\조여정\django-app\project2>ssh ubuntu@3.37.107.165 ubuntu@3.37.107.165: Permission denied (publickey). (venv) C:\Users\조여정\django-app\project2>ssh ubuntu@3.37.107.165 -i option requires an argument -- i usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address] [-c cipher_spec] [-D [bind_address:]port] [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file] [-J [user@]host[:port]] [-L address] [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address] [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]] destination [command] (venv) C:\Users\조여정\django-app\project2>ssh ubuntu@3.37.107.165 -i C:\Users\조여정\Downloads\lion.pem Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-1048-aws x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of Sat May 29 08:32:47 UTC 2021 System load: 0.0 Processes: 103 Usage of /: 26.1% of 7.69GB Users logged in: 0 Memory usage: 20% IPv4 address for eth0: 172.31.34.243 Swap usage: 0% * Super-optimized for small spaces - read how we shrank the memory footprint of MicroK8s to make it the smallest full K8s around. https://ubuntu.com/blog/microk8s-memory-optimisation Last login: Sat May 29 08:06:02 2021 from 39.127.68.135 ubuntu@ip-172-31-34-243:~$ source ../venv/bin/activate -bash: ../venv/bin/activate: No such file or directory ubuntu@ip-172-31-34-243:~$ python3 -m venv venv ubuntu@ip-172-31-34-243:~$ git clone https://github.com/NostalgiaJ/likelion django-app Cloning into 'django-app'... remote: Enumerating objects: 10530, done. remote: Counting objects: 100% (10530/10530), done. remote: Compressing objects: 100% (6595/6595), done. remote: Total 10530 (delta 2571), reused 10530 (delta 2571), pack-reused 0 Receiving objects: 100% (10530/10530), 23.21 MiB | 18.19 MiB/s, done. Resolving deltas: 100% (2571/2571), done. ubuntu@ip-172-31-34-243:~$ cd django-app/ ubuntu@ip-172-31-34-243:~/django-app$ source ../venv/bin/activate (venv) ubuntu@ip-172-31-34-243:~/django-app$ pip install -r requirements.txt ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt' (venv) ubuntu@ip-172-31-34-243:~/django-app$ cd project2/ (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ pip install -r requirements.txt Collecting asgiref==3.3.4 Downloading asgiref-3.3.4-py3-none-any.whl (22 kB) Collecting boto3==1.17.83 Downloading boto3-1.17.83-py2.py3-none-any.whl (131 kB) |████████████████████████████████| 131 kB 2.5 MB/s Collecting botocore==1.20.83 Downloading botocore-1.20.83-py2.py3-none-any.whl (7.6 MB) |████████████████████████████████| 7.6 MB 3.6 MB/s Collecting dj-database-url==0.5.0 Downloading dj_database_url-0.5.0-py2.py3-none-any.whl (5.5 kB) Collecting Django==3.2.3 Downloading Django-3.2.3-py3-none-any.whl (7.9 MB) |████████████████████████████████| 7.9 MB 23.9 MB/s Collecting django-storages==1.11.1 Downloading django_storages-1.11.1-py3-none-any.whl (42 kB) |████████████████████████████████| 42 kB 1.4 MB/s Collecting gunicorn==20.1.0 Downloading gunicorn-20.1.0-py3-none-any.whl (79 kB) |████████████████████████████████| 79 kB 10.2 MB/s Collecting jmespath==0.10.0 Downloading jmespath-0.10.0-py2.py3-none-any.whl (24 kB) Collecting Pillow==8.2.0 Downloading Pillow-8.2.0-cp38-cp38-manylinux1_x86_64.whl (3.0 MB) |████████████████████████████████| 3.0 MB 42.0 MB/s Collecting psycopg2-binary==2.8.6 Downloading psycopg2_binary-2.8.6-cp38-cp38-manylinux1_x86_64.whl (3.0 MB) |████████████████████████████████| 3.0 MB 38.2 MB/s Collecting python-dateutil==2.8.1 Downloading python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB) |████████████████████████████████| 227 kB 37.8 MB/s Collecting pytz==2021.1 Downloading pytz-2021.1-py2.py3-none-any.whl (510 kB) |████████████████████████████████| 510 kB 34.8 MB/s Collecting s3transfer==0.4.2 Downloading s3transfer-0.4.2-py2.py3-none-any.whl (79 kB) |████████████████████████████████| 79 kB 11.2 MB/s Collecting six==1.16.0 Downloading six-1.16.0-py2.py3-none-any.whl (11 kB) Collecting sqlparse==0.4.1 Downloading sqlparse-0.4.1-py3-none-any.whl (42 kB) |████████████████████████████████| 42 kB 1.8 MB/s Collecting urllib3==1.26.5 Downloading urllib3-1.26.5-py2.py3-none-any.whl (138 kB) |████████████████████████████████| 138 kB 41.2 MB/s Collecting whitenoise==5.2.0 Downloading whitenoise-5.2.0-py2.py3-none-any.whl (19 kB) Requirement already satisfied: setuptools>=3.0 in /home/ubuntu/venv/lib/python3.8/site-packages (from gunicorn==20.1.0->-r requirements.txt (line 7)) (44.0.0) Installing collected packages: asgiref, jmespath, six, python-dateutil, urllib3, botocore, s3transfer, boto3, dj-database-url, pytz, sqlparse, Django, django-storages, gunicorn, Pillow, psycopg2-binary, whitenoise Successfully installed Django-3.2.3 Pillow-8.2.0 asgiref-3.3.4 boto3-1.17.83 botocore-1.20.83 dj-database-url-0.5.0 django-storages-1.11.1 gunicorn-20.1.0 jmespath-0.10.0 psycopg2-binary-2.8.6 python-dateutil-2.8.1 pytz-2021.1 s3transfer-0.4.2 six-1.16.0 sqlparse-0.4.1 urllib3-1.26.5 whitenoise-5.2.0 (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ python manage.py runserver 3.37.107.165:8000 Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). You have 20 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): account, admin, auth, blog, contenttypes, sessions. Run 'python manage.py migrate' to apply them. May 29, 2021 - 08:36:44 Django version 3.2.3, using settings 'project2.settings' Starting development server at http://3.37.107.165:8000/ Quit the server with CONTROL-C. Error: That IP address can't be assigned to. (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ python manage.py migrate Operations to perform: Apply all migrations: account, admin, auth, blog, contenttypes, sessions Running migrations: Applying contenttypes.0001_initial... OK Applying contenttypes.0002_remove_content_type_name... OK Applying auth.0001_initial... OK Applying auth.0002_alter_permission_name_max_length... OK Applying auth.0003_alter_user_email_max_length... OK Applying auth.0004_alter_user_username_opts... OK Applying auth.0005_alter_user_last_login_null... OK Applying auth.0006_require_contenttypes_0002... OK Applying auth.0007_alter_validators_add_error_messages... OK Applying auth.0008_alter_user_username_max_length... OK Applying auth.0009_alter_user_last_name_max_length... OK Applying auth.0010_alter_group_name_max_length... OK Applying auth.0011_update_proxy_permissions... OK Applying auth.0012_alter_user_first_name_max_length... OK Applying account.0001_initial... OK Applying admin.0001_initial... OK Applying admin.0002_logentry_remove_auto_add... OK Applying admin.0003_logentry_add_action_flag_choices... OK Applying blog.0001_initial... OK Applying sessions.0001_initial... OK (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ python manage.py runserver 3.37.107.165:8000 Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). May 29, 2021 - 08:37:21 Django version 3.2.3, using settings 'project2.settings' Starting development server at http://3.37.107.165:8000/ Quit the server with CONTROL-C. Error: That IP address can't be assigned to. (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ ls Procfile README.md account blog db.sqlite3 manage.py project2 requirements.txt runtime.txt static (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ ipconfig Command 'ipconfig' not found, did you mean: command 'ifconfig' from deb net-tools (1.60+git20180626.aebd88e-1ubuntu1) command 'iconfig' from deb ipmiutil (3.1.5-1) command 'iwconfig' from deb wireless-tools (30~pre9-13ubuntu1) Try: sudo apt install <deb name> (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ path Command 'path' not found, did you mean: command 'mpath' from deb libmodule-path-perl (0.19-1) command 'xpath' from deb libxml-xpath-perl (1.44-1) command 'path6' from deb ipv6toolkit (2.0-1) command 'pat' from deb dist (1:3.5-236-0.1build1) command 'patch' from deb patch (2.7.6-6) Try: sudo apt install <deb name> (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ echo $path (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ echo (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ cd ../ (venv) ubuntu@ip-172-31-34-243:~/django-app$ python manage.py runserver 3.37.107.165:8000 python: can't open file 'manage.py': [Errno 2] No such file or directory (venv) ubuntu@ip-172-31-34-243:~/django-app$ cd project2/ (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ python manage.py runserver 3.37.107.165:8000 Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). May 29, 2021 - 08:47:11 Django version 3.2.3, using settings 'project2.settings' Starting development server at http://3.37.107.165:8000/ Quit the server with CONTROL-C. Error: That IP address can't be assigned to. (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ cd ../ (venv) ubuntu@ip-172-31-34-243:~/django-app$ sudo apt update && sudo apt -y upgrade Hit:1 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal InRelease Get:2 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB] Get:3 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB] Get:4 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [990 kB] Get:5 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB] Fetched 1318 kB in 1s (1169 kB/s) Reading package lists... Done Building dependency tree Reading state information... Done All packages are up to date. Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. (venv) ubuntu@ip-172-31-34-243:~/django-app$ sudo apt install -y python3 python3-pip python3-dev python3-venv build-essential libpq-dev vim git Reading package lists... Done Building dependency tree Reading state information... Done python3 is already the newest version (3.8.2-0ubuntu2). python3-dev is already the newest version (3.8.2-0ubuntu2). vim is already the newest version (2:8.1.2269-1ubuntu5). python3-venv is already the newest version (3.8.2-0ubuntu2). build-essential is already the newest version (12.8ubuntu1.1). git is already the newest version (1:2.25.1-1ubuntu3.1). libpq-dev is already the newest version (12.6-0ubuntu0.20.04.1). python3-pip is already the newest version (20.0.2-5ubuntu1.5). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. (venv) ubuntu@ip-172-31-34-243:~/django-app$ sudo reboot (venv) ubuntu@ip-172-31-34-243:~/django-app$ Connection to 3.37.107.165 closed by remote host. Connection to 3.37.107.165 closed. (venv) C:\Users\조여정\django-app\project2>pip install -r requirements.txt Requirement already satisfied: asgiref==3.3.4 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 1)) (3.3.4) Requirement already satisfied: boto3==1.17.83 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 2)) (1.17.83) Requirement already satisfied: botocore==1.20.83 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 3)) (1.20.83) Requirement already satisfied: dj-database-url==0.5.0 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 4)) (0.5.0) Requirement already satisfied: Django==3.2.3 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 5)) (3.2.3) Requirement already satisfied: django-storages==1.11.1 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 6)) (1.11.1) Requirement already satisfied: gunicorn==20.1.0 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 7)) (20.1.0) Requirement already satisfied: jmespath==0.10.0 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 8)) (0.10.0) Requirement already satisfied: Pillow==8.2.0 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 9)) (8.2.0) Requirement already satisfied: psycopg2-binary==2.8.6 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 10)) (2.8.6) Requirement already satisfied: python-dateutil==2.8.1 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 11)) (2.8.1) Requirement already satisfied: pytz==2021.1 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 12)) (2021.1) Requirement already satisfied: s3transfer==0.4.2 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 13)) (0.4.2) Requirement already satisfied: six==1.16.0 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 14)) (1.16.0) Requirement already satisfied: sqlparse==0.4.1 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 15)) (0.4.1) Requirement already satisfied: urllib3==1.26.5 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 16)) (1.26.5) Requirement already satisfied: whitenoise==5.2.0 in c:\users\조여정\django-app\venv\lib\site-packages (from -r requirements.txt (line 17)) (5.2.0) Requirement already satisfied: setuptools>=3.0 in c:\users\조여정\django-app\venv\lib\site-packages (from gunicorn==20.1.0->-r requirements.txt (line 7)) (57.0.0) (venv) C:\Users\조여정\django-app\project2>python manage.py runserver 3.37.107.165:8000 Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). May 29, 2021 - 17:52:22 Django version 3.2.3, using settings 'project2.settings' Starting development server at http://3.37.107.165:8000/ Quit the server with CTRL-BREAK. Error: That IP address can't be assigned to. (venv) C:\Users\조여정\django-app\project2>ssh ubuntu@3.37.107.165 -i C:\Users\조여정\Downloads\lion.pem Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-1048-aws x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information disabled due to load higher than 1.0 * Super-optimized for small spaces - read how we shrank the memory footprint of MicroK8s to make it the smallest full K8s around. https://ubuntu.com/blog/microk8s-memory-optimisation Last login: Sat May 29 08:32:48 2021 from 39.127.68.135 ubuntu@ip-172-31-34-243:~$ sudo apt update && sudo apt -y upgrade Hit:1 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal InRelease Hit:2 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal-updates InRelease Get:3 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB] Get:4 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB] Fetched 214 kB in 1s (161 kB/s) Reading package lists... Done Building dependency tree Reading state information... Done All packages are up to date. Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. ubuntu@ip-172-31-34-243:~$ sudo apt install -y python3 python3-pip python3-dev python3-venv build-essential libpq-dev vim git Reading package lists... Done Building dependency tree Reading state information... Done python3 is already the newest version (3.8.2-0ubuntu2). python3-dev is already the newest version (3.8.2-0ubuntu2). vim is already the newest version (2:8.1.2269-1ubuntu5). python3-venv is already the newest version (3.8.2-0ubuntu2). build-essential is already the newest version (12.8ubuntu1.1). git is already the newest version (1:2.25.1-1ubuntu3.1). libpq-dev is already the newest version (12.6-0ubuntu0.20.04.1). python3-pip is already the newest version (20.0.2-5ubuntu1.5). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. ubuntu@ip-172-31-34-243:~$ python3 -m venv venv ubuntu@ip-172-31-34-243:~$ git clone https://github.com/NostalgiaJ/likelion django-app fatal: destination path 'django-app' already exists and is not an empty directory. ubuntu@ip-172-31-34-243:~$ source ../venv/bin/activate -bash: ../venv/bin/activate: No such file or directory ubuntu@ip-172-31-34-243:~$ ssh ubuntu@3.37.107.165 -i C:\Users\조여정\Downloads\lion.pem Warning: Identity file C:Users조여정Downloadslion.pem not accessible: No such file or directory. The authenticity of host '3.37.107.165 (3.37.107.165)' can't be established. ECDSA key fingerprint is SHA256:ToUoWLlzdl6OmdppnHDz8546hlHXSNEibcuW2/gDYfE. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '3.37.107.165' (ECDSA) to the list of known hosts. ubuntu@3.37.107.165: Permission denied (publickey). ubuntu@ip-172-31-34-243:~$ python3 -m venv venv ubuntu@ip-172-31-34-243:~$ git clone https://github.com/NostalgiaJ/likelion django-app fatal: destination path 'django-app' already exists and is not an empty directory. ubuntu@ip-172-31-34-243:~$ cd django-app/ ubuntu@ip-172-31-34-243:~/django-app$ source ../venv/bin/activate (venv) ubuntu@ip-172-31-34-243:~/django-app$ pip install -r requirements.txt ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt' (venv) ubuntu@ip-172-31-34-243:~/django-app$ cd project2/ (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ pip install -r requirements.txt Requirement already satisfied: asgiref==3.3.4 in /home/ubuntu/venv/lib/python3.8/site-packages (from -r requirements.txt (line 1)) (3.3.4) Requirement already satisfied: boto3==1.17.83 in /home/ubuntu/venv/lib/python3.8/site-packages (from -r requirements.txt (line 2)) (1.17.83) Requirement already satisfied: botocore==1.20.83 in /home/ubuntu/venv/lib/python3.8/site-packages (from -r requirements.txt (line 3)) (1.20.83) Requirement already satisfied: dj-database-url==0.5.0 in /home/ubuntu/venv/lib/python3.8/site-packages (from -r requirements.txt (line 4)) (0.5.0) Requirement already satisfied: Django==3.2.3 in /home/ubuntu/venv/lib/python3.8/site-packages (from -r requirements.txt (line 5)) (3.2.3) Requirement already satisfied: django-storages==1.11.1 in /home/ubuntu/venv/lib/python3.8/site-packages (from -r requirements.txt (line 6)) (1.11.1) Requirement already satisfied: gunicorn==20.1.0 in /home/ubuntu/venv/lib/python3.8/site-packages (from -r requirements.txt (line 7)) (20.1.0) Requirement already satisfied: jmespath==0.10.0 in /home/ubuntu/venv/lib/python3.8/site-packages (from -r requirements.txt (line 8)) (0.10.0) Requirement already satisfied: Pillow==8.2.0 in /home/ubuntu/venv/lib/python3.8/site-packages (from -r requirements.txt (line 9)) (8.2.0) Requirement already satisfied: psycopg2-binary==2.8.6 in /home/ubuntu/venv/lib/python3.8/site-packages (from -r requirements.txt (line 10)) (2.8.6) Requirement already satisfied: python-dateutil==2.8.1 in /home/ubuntu/venv/lib/python3.8/site-packages (from -r requirements.txt (line 11)) (2.8.1) Requirement already satisfied: pytz==2021.1 in /home/ubuntu/venv/lib/python3.8/site-packages (from -r requirements.txt (line 12)) (2021.1) Requirement already satisfied: s3transfer==0.4.2 in /home/ubuntu/venv/lib/python3.8/site-packages (from -r requirements.txt (line 13)) (0.4.2) Requirement already satisfied: six==1.16.0 in /home/ubuntu/venv/lib/python3.8/site-packages (from -r requirements.txt (line 14)) (1.16.0) Requirement already satisfied: sqlparse==0.4.1 in /home/ubuntu/venv/lib/python3.8/site-packages (from -r requirements.txt (line 15)) (0.4.1) Requirement already satisfied: urllib3==1.26.5 in /home/ubuntu/venv/lib/python3.8/site-packages (from -r requirements.txt (line 16)) (1.26.5) Requirement already satisfied: whitenoise==5.2.0 in /home/ubuntu/venv/lib/python3.8/site-packages (from -r requirements.txt (line 17)) (5.2.0) Requirement already satisfied: setuptools>=3.0 in /home/ubuntu/venv/lib/python3.8/site-packages (from gunicorn==20.1.0->-r requirements.txt (line 7)) (44.0.0) (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ python manage.py runserver 3.37.107.165:8000 Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). May 29, 2021 - 08:58:15 Django version 3.2.3, using settings 'project2.settings' Starting development server at http://3.37.107.165:8000/ Quit the server with CONTROL-C. Error: That IP address can't be assigned to. (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ python manage.py runserver Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). May 29, 2021 - 08:58:47 Django version 3.2.3, using settings 'project2.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. ^C(venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ python manage.py runserver 3.37.107.165:8000 Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). May 29, 2021 - 09:03:07 Django version 3.2.3, using settings 'project2.settings' Starting development server at http://3.37.107.165:8000/ Quit the server with CONTROL-C. Error: That IP address can't be assigned to. (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ python manage.py runserver Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). May 29, 2021 - 09:03:13 Django version 3.2.3, using settings 'project2.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. 3.37.107.165 -i C:\Users\조여정\Downloads\lion.pem^Z [1]+ Stopped python manage.py runserver (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ python manage.py runserver 3.37.107.165:8000 Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). May 29, 2021 - 09:04:40 Django version 3.2.3, using settings 'project2.settings' Starting development server at http://3.37.107.165:8000/ Quit the server with CONTROL-C. Error: That IP address can't be assigned to. (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ python manage.py runserver 3.37.107.165 CommandError: "3.37.107.165" is not a valid port number or address:port pair. (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ python manage.py runserver 3.37.107.165:9000 Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). May 29, 2021 - 09:04:51 Django version 3.2.3, using settings 'project2.settings' Starting development server at http://3.37.107.165:9000/ Quit the server with CONTROL-C. Error: That IP address can't be assigned to. (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ python manage.py runserver 3.37.107.165:7000 Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). May 29, 2021 - 09:04:58 Django version 3.2.3, using settings 'project2.settings' Starting development server at http://3.37.107.165:7000/ Quit the server with CONTROL-C. Error: That IP address can't be assigned to. (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$ python manage.py runserver 3.37.107.165:8000 Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). May 29, 2021 - 09:05:02 Django version 3.2.3, using settings 'project2.settings' Starting development server at http://3.37.107.165:8000/ Quit the server with CONTROL-C. Error: That IP address can't be assigned to. (venv) ubuntu@ip-172-31-34-243:~/django-app/project2$
Bash
복사
deactivate
7. PostgreSQL 설치
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
해당 주소로 postgresql 을 추가..?
wget --quiet -0 - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt update
sudo apt -y install postgresql
sudo systemctl enable --now postgresql@13-main
⇒ 시스템 시작 시 자동 실행
sudo -u postgres createdb django
⇒ django 는 디비명,,, 원하는 이름 but django 추천
create user django with password 'p@ssword!';
⇒ 원하는 username 과 password 입력
alter role django set client_encoding to 'utf-8';
⇒ 인코딩 수정(한글 깨짐 방지)
alter role django set timezone to 'Asia/Seoul';
⇒ 시간 수정
grant all privileges on database django to django;
⇒ django 데이터베이스의 모든 권한을 django 유저에게 부여
8. settings.py 에 DB 설저
내 컴퓨터 VSCode → settings.py 열기
DATABASES = 부분을 다음과 같이 수정
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': os.environ.get('DB_NAME'), 'USER': os.environ.get('DB_USER'), 'PASSWORD': os.environ.get('DB_PASSWORD'), 'HOST': os.environ.get('DB_HOST'), 'PORT': '', } }
Python
복사
터미널에
git add -A
git commit -m "edit database"
git push
업데이트된 설정 서버에 가져오기(서버에서 실행)
cd /home/ubuntu/django-app
⇒ git 레포 클론한 위치로 가기
git pull
⇒ 유저네임, 패스워드 쓰네..?
source ../venv/bin/activate
pip install psycopg2
⇒ PostgreSQL 접속에 필요한 패키지 설치
환경변수 설정(임시/테스트용)
export DB_NAME=django
export DB_USER=django
export DB_PASSWORD='p@ssword!'
export DB_HOST=localhost
잘 작동하는지 테스트
python manage.py makemigrations
python manage.py migrate
python manage.py runserver 0.0.0.0:8000
http://내ElasticIP:8000 으로 접속해서 Django 화면이 표시되는지 확인
gunicorn 으로 Django App 실행
pip install gunicorn
⇒ 반드시 venv 안에서 실행
deactivate
⇒ 일단 가상환경 나옴
../venv/bin/gunicorn 프로젝트명.wsgi -b 0.0.0.0
⇒ project2
http://내ElasticIP:8000 으로 접속해서 Django 화면이 표시되는지 확인
⇒ 사진 안 뜨는거 정상 wsgi 가 static 관리 안함
systemd 에 gunicorn 등록
vi 에디터(폴더명, 파일명)
⇒ i 나 INSERT 키 누르면 변경 가능, esc 로 INSERT 해제
명령어 모드
: 치고 시작
:w → 저장
:q → 나가기
:wq → 저장하고 나가기
:q! → 강제로 나가기
sudo vi /etc/systemd/system/gunicorn.service
여기에 다음 코드 복사
[Unit] Description=gunicorn daemon Requires=gunicorn.socket After=network.target [Service] Type=notify RuntimeDirectory=gunicorn WorkingDirectory=/home/ubuntu/django-app ExecStart=/home/ubuntu/venv/bin/gunicorn 프로젝트명(project2).wsgi ExecReload=/bin/kill -s HUP $MAINPID KillMode=mixed TimeoutStopSec=5 PrivateTmp=true EnvironmentFile=/etc/gunicorn/env.conf [Install] WantedBy=multi-user.target
Bash
복사
sudo vi /etc/systemd/system/gunicorn.socket
여기에 다음 코드 복사
[Unit] Description=gunicorn.socket [Socket] ListenStream=/run/gunicorn.sock SocketUser=www-data [Install] WantedBy=sockets.target
Bash
복사
sudo mkdir /etc/gunicorn
sudo vi /etc/gunicorn/env.conf
여기에 다음 코드 복사
DB_NAME=django DB_USER=django DB_PASSWORD='p@ssword!' DB_HOST=localhost #기타 환경변수 여기에 입력? DEBUG=True #AWS_ACCESS_KEY ~~ 여기에 적으면 됨
Bash
복사
sudo systemctl daemon-reload
sudo systemctl enable --now gunicorn.socket
sudo systemctl enable --now gunicorn
⇒ 테스트
→ sudo systemctl status gunicorn
→ curl --unix-socket /run/gunicorn.sock.http
⇒ html 코드 나오면 정상
Nginx 설치
: 웹서버로 외부 세상과 Gunicorn 연결 역할
sudo apt -y install nginx
sudo vi /etc/nginx/stites-available/django_app
? django-app 아님?
여기에 다음 코드 복사
sever { listen 80; sever_name 내ElasticIP주소; # 도메인 연결하면 도메인 주소 넣으면 됨 location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /home/ubuntu/django-app; } location / { include proxy_params; proxy_pass http://unix:/run/gunicorn.sock; } }
Bash
복사
sudo ln -s /etc/nginx/sites-available/django_app /etc/nginx/sites-enabled
sudo nginx -t
sudo systemctl restart nginx
reload 연결 상관 x
restart 연결 끊고 새로 연결
http://내ElasticIP 으로 접속해서 Django 화면이 표시되는지 확인
source ../venv/bin/activate
python manage.py collectstatic
⇒ 이미지나 CSS 등 Static 파일들 보이게 됨