hyeonga_code

파이선 웹구축_장고_37_사이트 배포하기 (github, pythonanywhere) 본문

Python_Django

파이선 웹구축_장고_37_사이트 배포하기 (github, pythonanywhere)

hyeonga 2023. 6. 28. 05:59
반응형

- 사이트 배포

1. google.com > "git" 검색

2. win 64-bit 다운

3. "github.com" 회원가입

4. "www.pythonanywhere.com" 회원가입

- gui에서 작업하면 오래걸릴 수 있음

 

5. 'github' > 'your repositories' > 'new'

- 사이트 이름 설정

> 'create repositories'

 

6. cmd창 > 파일 저장 폴더까지 이동

C:\Users> cd c:\

c:\> cd mysite

c:\mysite> cd '폴더이름'

c:\mysite\'폴더이름'> git init

# git 다운받아야함

Initialized empty Git repository in C:/mysite/'폴더이름'/.git/

c:\mysite\'폴더이름'> git add .

# 하위 폴더에 .git 폴더 있으면 오류남

c:\mysite\'폴더이름'> git config --local user.name 'github가입시 사용한 아이디'

#_ 띄어쓰기 주의

c:\mysite\'폴더이름'> git config --local user.email '사용자이메일주소(github)'

c:\mysite\'폴더이름'>git config --local user.name 'hyeonga493'

c:\mysite\'폴더이름'>git config --local user.email 'hyeonga4349@naver.com'

c:\mysite\'폴더이름'>git commit -m "first commit"

On branch main

nothing to commit, working tree clean

 

c:\mysite\'폴더이름'>git branch -M main

c:\mysite\'폴더이름'>git remote add origin https://github.com/hyeonga493/site.git

error: remote origin already exists.

c:\mysite\'폴더이름'>git push -u origin main

>> code로 시작하기

>> code로 인증 시, 폴더 뜸

 

Enumerating objects: 146, done.

Counting objects: 100% (146/146), done.

Delta compression using up to 8 threads

Compressing objects: 100% (139/139), done.

Writing objects: 100% (146/146), 872.99 KiB | 15.32 MiB/s, done.

Total 146 (delta 37), reused 0 (delta 0), pack-reused 0

remote: Resolving deltas: 100% (37/37), done.

To https://github.com/hyeonga493/site.git

* [new branch] main -> main

branch 'main' set up to track 'origin/main'.

 

 

 

- git 페이지 "www.pythonanywhere.com"

'bash' 클릭

=====

git

07:20 ~ $ https://github.com/'사용자 아이디'/'사이트 이름'.git

bash: https://github.com/'사용자 아이디'/'사이트 이름'.git: No such file or directory

# 오류 : 설치가 안되어 있음

07:20 ~ $ git clone https://github.com/'사용자 아이디'/'사이트 이름'

# pip와 동일한 기능

Cloning into 'site'...

remote: Enumerating objects: 146, done.

remote: Counting objects: 100% (146/146), done.

remote: Compressing objects: 100% (102/102), done.

remote: Total 146 (delta 37), reused 146 (delta 37), pack-reused 0

Receiving objects: 100% (146/146), 872.99 KiB | 16.47 MiB/s, done.

Resolving deltas: 100% (37/37), done.

Updating files: 100% (128/128), done.

 

 

- 페이지 작성 시, 다운받았던 파이선 프로그램 전부 설치

 

07:23 ~ $ pip install googletrans==4.0.0rc1

07:23 ~ $ pip install pillow

07:23 ~ $ pip install gTTS

07:23 ~ $ pip install django-mathfilters

 

07:23 ~ $ python

#_ 파이선 버전 확인 ('www.pythonanywhere.com'에서 필요)

Python 3.10.5 (main, Jul 22 2022, 17:09:35) [GCC 9.4.0] on linux

Type "help", "copyright", "credits" or "license" for more information

 

'삼지창' > 'web' 클릭 > 'add a new web app'

 

- hyeonga.pythonanywhere.com. 으로 해야한다고 알려줌

1) next

2) manual configuration 클릭

3) 확인한 파이선 버전 클릭

 

1. Code: 아래 'Working directory' / 'manage.py있는 폴더'

 

 

2. WSGI configuration file:/var/www/hyeonga1004_pythonanywhere_com_wsgi.py

- 76-89 line [Ctrl] + [/] _주석 해제

=====

1) mysite > 'manage.py있는 폴더'로 수정

2) path = '/home/hyeonga/[manage.py있는 폴더]'

3) mysite > config 수정

4) os.environ['DJANGO_SETTINGS_MODULE'] = 'config.settings'

 

 

3. reload

 

site/

 

Source Code : 'go to directory' > 'config' > 'settings.py'

=====

ALLOWED_HOSTS = ['*']

#_ 문자열로 전체를 허용

 

> 저장 > reload > 실행

 

반응형