테스트 사이트 - 개발 중인 베타 버전입니다

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

· 2년 전 · 805 · 3

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

 

 

 

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 으로 접속하면 아래와 같은 화면이 나옵니다.


댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

댓글 3개

다중 도메인의 경우 paaa 부분을 pbbb 로, 포트 1111 을 2222 와 같은 방식으로 추가 작업하시면 됩니다.
uwsgi 를 reload 하는 경우 아래 명령을 사용하세요.

uwsgi --reload uwsgi.pid
pip , uwsgi 설치 참고 사이트

https://www.sysnet.pe.kr/2/0/12881

게시글 목록

번호 제목
831
830
829
827
824
823
821
819
818
814
809
808
807
806
803
801
799
798
797
796
794
786
783
782
767
742
655
614
591
590