码迷,mamicode.com
首页 > 其他好文 > 详细

Django 部署 uwsgi + nginx + supervisor

时间:2016-10-23 09:36:19      阅读:316      评论:0      收藏:0      [点我收藏+]

标签:redirect   ddr   data   connect   alias   err   env   wsgi   配置文件   

Django 部署 uwsgi + nginx + supervisor

https://hacpai.com/article/1460607620615?p=1&m=0

更新依赖

pip install uwsgi

编辑配置文件 uwsgi.ini

[uwsgi]
# Django-related settings
chdir           = /home/zonghua/Documents/test_project
module          = test_project.wsgi:application
env             = DJANGO_SETTINGS_MODULE=test_project.settings_production
home            = /home/zonghua/Documents/test_project/venv
reload-mercy    = 10
user            = zonghua
uid             = zonghua
pcre-jit
thunder-lock
enable-threads
master          = True
threads         = 2
processes       = 4
socket          = 127.0.0.1:8001
chmod-socket    = 664
vacuum          = true

执行命令

uwsgi --ini uwsgi.ini 

运行情况

[uwsgi](https://hacpai.com/tag/uwsgi) getting INI configuration from /home/zonghua/Documents/test_project/uwsgi.ini
*** Starting uWSGI 2.0.12 (64bit) on [Tue Apr  5 13:59:02 2016] ***
compiled with version: 5.2.1 20151010 on 04 April 2016 01:12:07
os: Linux-4.2.0-34-generic #39-Ubuntu SMP Thu Mar 10 22:13:01 UTC 2016
nodename: x
machine: x86_64
clock source: unix
pcre jit enabled
detected number of CPU cores: 4
current working directory: /home/zonghua/Documents/test_project
detected binary path: /home/zonghua/Documents/test_project/venv/bin/uwsgi
chdir() to /home/zonghua/Documents/test_project
your processes number limit is 11829
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: enabled
uwsgi socket 0 bound to TCP address 127.0.0.1:8001 fd 3
Python version: 2.7.10 (default, Oct 14 2015, 16:09:02)  [GCC 5.2.1 20151010]
Set PythonHome to /home/zonghua/Documents/test_project/venv
Python main interpreter initialized at 0x93b180
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 415360 bytes (405 KB) for 8 cores
*** Operational MODE: preforking+threaded ***
WSGI app 0 (mountpoint=‘‘) ready in 1 seconds on interpreter 0x93b180 pid: 2781 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 2781)
spawned uWSGI worker 1 (pid: 2784, cores: 2)
spawned uWSGI worker 2 (pid: 2785, cores: 2)
spawned uWSGI worker 3 (pid: 2787, cores: 2)
spawned uWSGI worker 4 (pid: 2789, cores: 2)

nginx 配置 文件 /etc/nginx/site-avaiable/test

server {
    listen 80;
    charset utf-8;
    client_max_body_size 75M;
    location /media {
        alias /path/to/project/media;
    }
    location /static {
       alias /path/to/project/static;
   }
    location / {
        uwsgi_pass 127.0.0.1:8001;
        include uwsgi_params;
    }
}

supervisor 配置文件 /etc/supervisor/supervisor.conf

[program:test]
directory= /home/zonghua/Documents/test_project
command = /home/zonghua/Documents/test_project/venv/bin/uwsgi --ini /home/zonghua/Documents/test_project/uwsgi.ini
user = zonghua
autostart = true
autorestart = true
stopsignal = QUIT
redirect_stderr = true
loglevel = error
stdout_logfile = /home/zonghua/Documents/test_project/logs/uwsgi_out.log
stderr_logfile = /home/zonghua/Documents/test_project/logs/uwsgi_err.log
logfile_maxbytes = 1M

热加载需要指定一个 pidfile,待添加。

Django 部署 uwsgi + nginx + supervisor

标签:redirect   ddr   data   connect   alias   err   env   wsgi   配置文件   

原文地址:http://www.cnblogs.com/xiaojikuaipao/p/5989003.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!