일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- 연습문제
- 가상 메모리 기초
- 스프링 APPLICATION_JSON_UTF8
- 알고리즘
- 문제 풀이
- CPU 스케줄링
- chapter8
- 네트워크와 분산 시스템
- 물리 메모리 관리
- CloudFunction
- Java
- GCP PubSub
- JSON encoding
- PubSub
- 브라우저 JSON 인코딩
- Algorithm
- github personal access token
- github 403
- 브라우저 JSON encoding
- heap
- 코딩테스트
- 운영체제
- github access token
- github push 403
- JSON UTF-8
- codingtest
- 요리책 운영체제
- 요리책
- chapter7
- Python
- Today
- Total
이도(李裪)
uwsgi, nginx + Django 본문
Django에 uwsgi, nginx로 배포하면서 에러 겪는거 정리
uwsgi official docs 따라하면서 설치했다
https://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html
Setting up Django and your web server with uWSGI and nginx — uWSGI 2.0 documentation
About the domain and port In this tutorial we will call your domain example.com. Substitute your own FQDN or IP address. Throughout, we’ll be using port 8000 for the web server to publish on, just like the Django runserver does by default. You can use what
uwsgi-docs.readthedocs.io
1. uwsgi 설치할 때 C compiler 없다고 에러 뜨는거
해결: C compiler 설치하면 된다
https://uwsgi-docs.readthedocs.io/en/latest/Install.html
Installing uWSGI — uWSGI 2.0 documentation
Alternative build profiles For historical reasons when you run ‘make’, uWSGI is built with Python as the only supported language. You can build customized uWSGI servers using build profiles, located in the buildconf/ directory. You can use a specific profi
uwsgi-docs.readthedocs.io
문서에 잘 나와있다 그리고 여기에서 python-dev라 나와있는건 자기 버전에 맞게 설치하면 된다
(sudo) apt-get install build-essential
# apt-get install python # python은 설치 안해도 된다 이미 설치되어있다
# python3.6 버전 쓰고 있으니까
(sudo) apt-get install python3.6-dev
2. --chmod-socket=666은 되는데 664는 안되는거
아직도 이 부분은 확실히 잘 모르겠다. 도움이 필요하다
맨 마지막에는 된다
조치했던 거
1) 현재 유저를 www-data 그룹에 추가
# ubuntu(유저네임)를 www-data 그룹을 primary group으로 지정
sudo usermod -g www-data ubuntu
# 그러먼 ubuntu의 기존 primary group이었던 ubuntu가 사라짐
# 혹시 몰라서 secondary 그룹에 추가해놓음
sudo usermod -aG ubuntu ubuntu
이렇게 해 놓으면 ubuntu 유저로 만든 파일, 폴더들의 group이 www-data로 자동으로 변경된다
여기까지 해 놓아도 664는 되지는 않았다 ㅠ
아래 3을 계속 읽자 이어지는 이야기이다
3. sudo uwsgi --emperor /etc/uwsgi/vassals --uid www-data --gid www-data 실행이 안됨
--uid를 ubuntu로 바꾸어도 안되더라
여기까지 오면 일단 다 된거임
systemctl 등록해서 부팅시에 uwsgi 실행하게 만들면 됨
1)
sudo vi /etc/systemd/system/uwsgi.service
[Unit]
Description=uWSGI Emperor
After=syslog.target
[Service]
ExecStart=/usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals/denpick_uwsgi.ini
RuntimeDirectory=uwsgi
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
systemctl 등록해놓는거다
system service 등록은 여기 참고했다
2)
sudo vi /etc/uwsgi/vassals/denpick_uwsgi.ini
[uwsgi]
chdir = /home/ubuntu/DentalMaterial
module = app.wsgi
home = /home/ubuntu/DentalMaterial/venv
master = true
processes = 5
socket = /home/ubuntu/uwsgi/denpick.sock
chmod-socket = 664
chown-socket = ubuntu:www-data
vacuum = true
denpick_uwsgi.ini에서 눈여겨 보아야할 게
1. chmod-socket = 664
2. chown-socket = ubuntu:www-data
3. vacuum = true
왜인지 모르겠는데 여기서는 chmod, chown이 잘 먹는다
그리고 vaccum=true하면 denpick.sock 파일이 사라져서
할 때마다 만들어줘야하는데
true로 해놔도 --emperor 모드여서 그런지 할 때마다 새로 생기는 듯하다
3)
마지막으로 명령어 등록해놓는다
sudo vi ~/.bashrc
alias dduwsgi='sudo systemctl restart uwsgi'
alias ddnginx='sudo /etc/init.d/nginx reload'