Coder Social home page Coder Social logo

maro99 / ec2-deploy-review Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 1.29 MB

AWS ec2 사용해서 기본적인 배포해보는중. (ec2에서 uwsgi 로 배포-->Docker안에서 nginx,uwsgi 로 배포 --> RDS, S3 적용까지해봄.)

Python 60.56% Shell 29.88% HTML 4.07% Dockerfile 5.50%

ec2-deploy-review's Introduction

Nginx - uWSGI - Django

Web Server <-> WSGI <-> Web Application

Requirements

  • Python (3.6)
  • pipenv

Secrets

.secrets/base.json

{
  "SECRET_KEY": "<Django secret key>"
}

.secrets/dev.json

  • PostgreSQL을 사용, DATABASES섹션의 설정이 필요
{
  "DATABASES": {
    "default": {
      "ENGINE": "django.db.backends.postgresql",
      "HOST": "<host>",
      "PORT": 5432,
      "USER": "<user>",
      "PASSWORD": "<password>",
      "NAME": "<db name>"
    }
  }
}

Installation

pipenv install
pipenv shell
cd app
./manage.py runserver

Nginx

웹 서버 설정

/etc/nginx/nginx.conf
  • user: nginx 프로세스를 실행할 유저
  • daemon: off로 나타낼 시, background가 아닌 foreground프로세스로 실행
    • nginx -g 'daemon off;' <- 이것과 같은 효과가 됨

운영가능한 가상서버(Virtual host)

A, B, C, D, E 5개의 서버정보가 있다면, sites-available폴더에 들어있음

/etc/nginx/sites-available/*

실제 운용중인 가상서버

sites-available폴더에 있는 파일을 링크해서 사용

/etc/nginx/sites-enabled/<링크파일>

링크 명령어

ln -s <소스> <타겟>

Nginx와 uWSGI

Web Server <-> WSGI

서로간에 Unix socket을 사용해서 연결 /tmp/app.sock을 사용

이 때, uWSGINginx를 실행하는 프로세스들이 모두 해당 소켓파일에 접근할 권한이 있어야 함.

(실습때는 uWSGINginx모두 root계정을 사용해서 해결)

Nginx에서

자신의 가상서버 설정 (server블록)의 location에서, uwsgi_pass부분에 유닉스 소켓 프로토콜과 위치(unix://, /tmp/app.sock)을 지정

uWSGI에서

uWSGI를 실행하기 위한 설정파일 (uwsgi.ini)의 socket항목에 /tmp/app.sock을 지정

uWSGI

uWSGI의 설정은 <파일명>.ini파일에 ini방식으로 설정을 기술.

  • chdir: 웹 애플리케이션의 파이썬 프로젝트 루트 폴더
  • home: 실행할 파이썬 가상환경 / 파이썬 인터프리터의 위치
  • module: 웹 애플리케이션에서 WSGI프레임워크와의 연결을 기술한 파이썬 모듈

uWSGI와 Django

: WSGI <-> Web Application

서로간의 연결에 웹 애플리케이션(Django)의 config.wsgi모듈 (app/config/wsgi.py파일)을 사용

ec2-deploy-review's People

Contributors

maro99 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.