AWS Lightsail Django 인스턴스에 uwsgi, NGINX 설치후 도메인 연결하기 > 파이썬

파이썬

그누 어디까지 써봤니? 나는 파이썬까지 써봤어!

AWS Lightsail Django 인스턴스에 uwsgi, NGINX 설치후 도메인 연결하기 정보

AWS Lightsail Django 인스턴스에 uwsgi, NGINX 설치후 도메인 연결하기

첨부파일

ssh.txt (2.1K) 0회 다운로드 2023-06-30 14:48:07

본문

https://lightsail.aws.amazon.com/ 에서 Django 인스턴스를 선택합니다.
테스트 용이므로 인스턴스 플랜(요금)은 10$ 짜리로 추천합니다.

 

3717582117_1688096960.0758.png

 

 

SSH 로 연결하여 아래 굵은 글씨 부분의 명령을 실행합니다.

 

$ ls
bitnami_credentials  htdocs  stack

 

$ sudo apt install python3-pip -y
Reading package lists... Done
...
Processing triggers for libc-bin (2.31-13+deb11u5) ...

 

$ python3 -m pip install --upgrade pip
Defaulting to user installation because normal site-packages is not writeable
...
Successfully installed pip-23.1.2

 

$ pip install uwsgi
Defaulting to user installation because normal site-packages is not writeable
...
Successfully installed uwsgi-2.0.21


$ vi ~/.bashrc

PATH=/home/bitnami/.local/bin:$PATH
PATH=/opt/bitnami/apache/bin:...:$PATH 
export PATH
...

 

$ source ~/.bashrc

 

$ django-admin startproject paaa

 

$ ls
bitnami_application_password  bitnami_credentials  htdocs  paaa  stack

 

$ cd paaa

 

$ vi paaa/settings.py

 

ALLOWED_HOSTS = ['*']
...
import os
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

STATIC_URL = '/static/'

 

$ python manage.py collectstatic

128 static files copied to '/home/bitnami/paaa/static'.

 

$ vi uwsgi.ini

 

[uwsgi]
socket=127.0.0.1:1111
module=paaa.wsgi:application
processes=2
chmod-socket=666
pidfile=./uwsgi.pid
daemonize=./uwsgi.log
log-reopen=true
die-on-term=true
master=true
vacuum=true

 

$ uwsgi --ini uwsgi.ini 

[uWSGI] getting INI configuration from uwsgi.ini

 

$ sudo apt install nginx -y
Reading package lists... Done
...
Processing triggers for libc-bin (2.31-13+deb11u5) ...##################################.] 


$ sudo su

 

# cd /etc/nginx/sites-enabled/

 

# ls
default

 

# cp default paaa

 

# unlink default

 

# ls
paaa

 

# vi paaa

 

server {
        listen 80;

        server_name paaa.pypot.com; # 본인의 도메인

        location / {
                uwsgi_pass 127.0.0.1:1111;
                include /etc/nginx/uwsgi_params;
        }

        location /static {
                alias /home/bitnami/paaa/static;
        }

}

 

# systemctl restart nginx
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.

 

# killall httpd

 

# systemctl restart nginx


브라우에서 paaa.pypot.com 으로 접속하면 아래와 같은 화면이 나옵니다.


3717582117_1688104068.0433.png

추천
2

댓글 3개

전체 121 |RSS
파이썬 내용 검색

회원로그인

진행중 포인트경매

  1. 참여4 회 시작24.04.25 20:23 종료24.05.02 20:23
(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT