티스토리 뷰
(Raspbian)[RaspberryPi][django] project Deploy 사전준비
jinozpersona 2019. 12. 13. 12:25INTRO
- 뼈대만들기 : (Raspbian)[RaspberryPi][django] project 뼈대만들기
- 배포준비하기 : Domain 연결 및 git 사용하기
0. django SECRET_KEY 설정
SECRET_KEY 보안 설정
--nanoEditor : secret.json
{
"SECRET_KEY": "Your-SECRET_KEY"
}
--nanoEditor : settings.py
import os, json
from django.core.exceptions import ImproperlyConfigured
....
secret_file = os.path.join(BASE_DIR,'secret.json')
with open(secret_file) as f:
secret = json.loads(f.read())
def get_secret(setting, secret=secret):
try:
return secret[setting]
except KeyError:
raise ImproperlyConfigured(error_msg)
SECRET_KEY = get_secret("SECRET_KEY")
....
1. Domain 연결하기
- nginx 심볼릭링크 제거 : 기존 EMP(Enginx+MariaDB+PHP) 설정에 사용했던 default 제거
$ sudo rm -f /etc/nginx/sites-enabled/default
/etc/nginx/sites-enabled에 default는 지우고 다음 심볼릭 링크만 남겨놓는다.
django_project_nginx.conf -> [[django_project]]/django_project_nginx.conf
- django 연결하기 : ALLOWED_HOSTS domain 추가 및 django_project_nginx.conf server port 변경
--nanoEditor : settings.py
....
DEBUG = False
ALLOWED_HOSTS = ['Your-Domain']
....
--
--nanoEditor : django_project_nginx.conf
....
# configuration of the server
server {
# the port your site will be served on
listen 80;
....
--
- nginx 재기동
$ sudo /etc/init.d/nginx restart
2. github 사용하기
- .gitignore 생성
(jbe)[[django_project]]$ nano .gitignore
--nanoEditor : .gitignore
*.log
*.pyc
__pycache__/
secret.json
media/
mediafiles/
static/
staticfiles/
test.py
uwsgi_params
django_project.sock
django_project.ini
django_project_nginx.conf
$ sudo apt update
$ sudo apt upgrade
$ sudo apt install git-core
(jbe)[[django_project]]$ git init
(jbe)[[django_project]]$ git remote add origin https://github.com/UserID/repo_name.git
(jbe)[[django_project]]$ git remote -v
(jbe)[[django_project]]$ git add .
(jbe)[[django_project]]$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached ..." to unstage)
....
(jbe)[[django_project]]$ git config --global user.email "you@example.com"
(jbe)[[django_project]]$ git config --global user.name "Your Name"
(jbe)[[django_project]]$ git commit -m "First git test"
[master (root-commit) 3cd8ae3] Firtst commit test
17 files changed, 351 insertions(+)
create mode 100644 .gitignore
...
(jbe)[[django_project]]$ git status
On branch master
nothing to commit, working tree clean
(jbe)[[django_project]]$ git push -f orign master
Github site에서 push된 파일을 확인한다.
참고. git init 삭제
$ rm -rf .git
'Raspberry Pi > Webapp_django' 카테고리의 다른 글
(Raspbian)[RaspberryPi][django] project 뼈대만들기 (0) | 2019.12.11 |
---|
- Total
- Today
- Yesterday
- r
- raspberrypi
- MacOS
- sublime text
- server
- 코로나
- 확진
- CSV
- git
- Raspberry Pi
- pyserial
- Templates
- github
- 라즈베리파이
- vscode
- ERP
- Pandas
- analysis
- template
- 자가격리
- arduino
- 코로나19
- SSH
- Model
- Django
- Python
- COVID-19
- Regression
- DAQ
- DS18B20
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |