AWS Lightsail Django 인스턴스에 uwsgi, NGINX 설치후 도메인 연결하기 정보
AWS Lightsail Django 인스턴스에 uwsgi, NGINX 설치후 도메인 연결하기첨부파일
본문
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 으로 접속하면 아래와 같은 화면이 나옵니다.
2
댓글 3개
uwsgi --reload uwsgi.pid