From 8c58a585bac6c9d5285db65f3d8e9bf99028d422 Mon Sep 17 00:00:00 2001 From: shchoi94 Date: Fri, 1 Jan 2021 12:12:14 +0000 Subject: [PATCH] ec2 local settings #1 --- deployment/README_deployment.txt | 11 ++++++++++ deployment/sites-available/written.conf | 29 +++++++++++++++++++++++++ deployment/sites-enabled/written.conf | 1 + written/uwsgi_params | 17 +++++++++++++++ written/written/settings.py | 9 ++++++-- written/written_uwsgi.ini | 26 ++++++++++++++++++++++ 6 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 deployment/README_deployment.txt create mode 100644 deployment/sites-available/written.conf create mode 120000 deployment/sites-enabled/written.conf create mode 100644 written/uwsgi_params create mode 100644 written/written_uwsgi.ini diff --git a/deployment/README_deployment.txt b/deployment/README_deployment.txt new file mode 100644 index 0000000..3317a16 --- /dev/null +++ b/deployment/README_deployment.txt @@ -0,0 +1,11 @@ +#ec2 local settings + +#location + +/etc/nginx/sites-available/written.conf + +/etc/nginx/sites-enabled/ + +#command +$ sudo ln -s /etc/nginx/sites-available/written.conf /etc/nginx/sites-enabled/written.conf + diff --git a/deployment/sites-available/written.conf b/deployment/sites-available/written.conf new file mode 100644 index 0000000..225180d --- /dev/null +++ b/deployment/sites-available/written.conf @@ -0,0 +1,29 @@ +server { + listen 80 default; + server_name _; + + location / { + uwsgi_pass unix://home/ec2-user/written_uwsgi.sock; + include /home/ec2-user/team7-server/written/uwsgi_params; + # return 301 https://$server_name$request_uri; + } +} +# +#server { +# listen 443 ssl default; +# server_name shchoi.shop www.shchoi.shop; +# +# ssl_certificate /etc/letsencrypt/live/www.shchoi.shop/fullchain.pem; +# ssl_certificate_key /etc/letsencrypt/live/www.shchoi.shop/privkey.pem; +# +# error_page 497 https://$server_name$request_uri; +# +# location / { +# uwsgi_pass unix://home/ec2-user/written.sock; +# include /home/ec2-user/team7-server/written/uwsgi_params; +# } +# +# location /static/ { +# root /home/ec2-user/waffle-rookies-18.5-backend-2/waffle_backend; +# } +#} diff --git a/deployment/sites-enabled/written.conf b/deployment/sites-enabled/written.conf new file mode 120000 index 0000000..7146f95 --- /dev/null +++ b/deployment/sites-enabled/written.conf @@ -0,0 +1 @@ +/etc/nginx/sites-available/written.conf \ No newline at end of file diff --git a/written/uwsgi_params b/written/uwsgi_params new file mode 100644 index 0000000..5ec282a --- /dev/null +++ b/written/uwsgi_params @@ -0,0 +1,17 @@ +uwsgi_param QUERY_STRING $query_string; +uwsgi_param REQUEST_METHOD $request_method; +uwsgi_param CONTENT_TYPE $content_type; +uwsgi_param CONTENT_LENGTH $content_length; + +uwsgi_param REQUEST_URI $request_uri; +uwsgi_param PATH_INFO $document_uri; +uwsgi_param DOCUMENT_ROOT $document_root; +uwsgi_param SERVER_PROTOCOL $server_protocol; +uwsgi_param REQUEST_SCHEME $scheme; +uwsgi_param HTTPS $https if_not_empty; + +uwsgi_param REMOTE_ADDR $remote_addr; +uwsgi_param REMOTE_PORT $remote_port; +uwsgi_param SERVER_PORT $server_port; +uwsgi_param SERVER_NAME $server_name; + diff --git a/written/written/settings.py b/written/written/settings.py index 1793e6f..3831d4a 100644 --- a/written/written/settings.py +++ b/written/written/settings.py @@ -26,7 +26,12 @@ DEBUG = True DEBUG_TOOLBAR = os.getenv('DEBUG_TOOLBAR') in ('true', 'True') -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = [ + '13.125.159.22', + 'localhost', + '127.0.0.1', + + ] # Application definition @@ -81,7 +86,7 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', - 'HOST': '127.0.0.1', + 'HOST': 'terraform-20201229022238060000000001.cm6tz6yvqwf5.ap-northeast-2.rds.amazonaws.com',#개인 로컬 컴퓨터는 127.0.0.1 'PORT': 3306, 'NAME': 'written_waffle', 'USER': 'written-waffle', diff --git a/written/written_uwsgi.ini b/written/written_uwsgi.ini new file mode 100644 index 0000000..0adb6ff --- /dev/null +++ b/written/written_uwsgi.ini @@ -0,0 +1,26 @@ +[uwsgi] +# Django-related settings +# the base directory (full path) +chdir = /home/ec2-user/team7-server/written +# Django's wsgi file +module = written.wsgi:application +# the virtualenv (full path) +home = /home/ec2-user/.pyenv/versions/venv_written +virtualenv = /home/ec2-user/.pyenv/versions/venv_written +# the socket (use the full path to be safe +socket = /home/ec2-user/written_uwsgi.sock +chmod-socket = 666 + +# process-related settings +# master +master = true +enable-threads = true +pidfile = /tmp/written_uwsgi.pid + +vacuum = true +daemonize = /home/ec2-user/written_uwsgi.log +lazy-apps = true + +buffer-size = 65535 +max-requests = 500 +