Ubuntu???Django+uWSGI+nginx??????
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ubuntu???Django+uWSGI+nginx??????相关的知识,希望对你有一定的参考价值。
?????????gen ble ????????? for init.d .so ?????? ati ini??????
????????????uwsgi+nginx?????????django
??????????????????nginx?????????????????????????????????web?????????????????????????????????Nginx???????????????????????????????????????????????????????????????????????????uwsgi?????????Django??????Django??????????????????????????????web?????????
uwsgi
pip3 install uwsgi
??????:uwsgi --http :8080 --module mall.wsgi
http ??? ????????????????????????
processes ??? ?????????????????????
workers ??? ?????????????????????????????????processes?????????????????????spawn the specified number ofworkers / processes???
chdir ??? ?????????????????????chdir to specified directory before apps loading???
wsgi-file ??? ??????wsgi-file???load .wsgi file???
stats ??? ?????????????????????????????????????????????enable the stats server on the specified address???
threads ??? ?????????????????????GIL????????????????????????????????????????????????run each worker in prethreaded mode with the specified number of threads???
master ??? ????????????????????????enable master process???
daemonize ??? ????????????????????????????????????????????????????????????????????????udp????????????daemonize uWSGI????????????????????????????????????????????????????????????????????????????????????
pidfile ??? ??????pid????????????????????????????????????pid??????
vacuum ??? ??????????????????????????????????????????????????????unix socket?????????pid?????????try to remove all of the generated file/sockets???
???.Nginx+uwsgi+Django
Params uwsgi_params
Nginx???????????? nginx.conf
uwsgi???????????? uwsgi.ini
??????uwsgi
??????uwsgi.ini??????
[uwsgi]
socket = :8000 # ?????????
master = true # ?????????????????????
processes = 4
workers = 5 # ????????????
enable-threads = true
post-buffering = 4096
chdir = /root/masami/luntan # ??????????????????
home = /root/masami/env # ?????????????????????
module = luntan.wsgi:application
vacuum = true
socket = /root/masami/uwsgi.sock # uwsgi.sock??????????????????
??????
uwsgi --ini uwsgi.ini
Nginx
Nginx??????
sudo apt-get install nginx
????????????
/etc/init.d/nginx start # ??????
/etc/init.d/nginx stop # ??????
/etc/init.d/nginx restart # ??????
?????????????????????
mkdir /var/log/nginx/masami/ # ?????????????????????????????????????????????
????????????
?????? /etc/nginx/sites-availabel???
??????????????????????????????????????????????????????
??????default???????????????
touch masami # ??????masami???????????????????????????????????????
server { listen 80; server_name localhost; charset utf-8; client_max_body_size 75M; # ???????????????????????? access_log /var/log/nginx/masami/Masami_access.log; error_log /var/log/nginx/masami/Masami_error.log; location /media { alias /root/masami/luntan/media; } location /static { alias /root/masami/luntan/static; } location / { uwsgi_pass 127.0.0.1:8000; include /etc/nginx/uwsgi_params; } }
??????nginx?????????????????? nginx -t
??????????????????403?????????
??????/etc/nginx/nginx.conf ??????
??????????????????user root;
??????nginx
supervidor
??????
supervidor ?????????python2
????????????
echo_supervisord_conf > /etc/supervisord/supervisord.conf
以上是关于Ubuntu???Django+uWSGI+nginx??????的主要内容,如果未能解决你的问题,请参考以下文章
python3 + Django + uwsgi + nginx 配置部署笔记
Nginx、uwsgi、django、ubuntu 16 带有静态文件的问题
ubuntu 16 安装django nginx uWSGI