Django 部署 uwsgi + nginx + supervisor

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

zonghua • 6 个月前 • 浏览 1.7K • 回帖 15
Python  Django  uwsgi  NGINX 

更新依赖

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的更多相关文章

  1. [py]django上线部署-uwsgi+nginx+py3/django1.10

    https://github.com/lannyMa/django-uwsgi-nginx.git 单机调试启动-确保项目代码没问题 - 克隆代码进入项目 git clone https://gith ...

  2. django 本地项目部署uwsgi 以及云服务器部署 uwsgi+Nginx+Docker+MySQL主从

    一 .django 本地项目部署uwsgi 1 本地部署项目 uwsgi安装测试 通过uwsgi 进行简单部署 安装uwsgi命令:pip install uwsgi -i http://pypi.d ...

  3. django自带wsgi server vs 部署uwsgi+nginx后的性能对比

    一.下面先交代一下测试云主机 cpu: root@alexknight:/tmp/webbench-1.5# cat /proc/cpuinfo |grep model model : model n ...

  4. ubuntu 部署Django项目+uwsgi+Nginx

    1.部署框架 Nginx负责静态资源请求,并且把无法处理的请求转发至uwsgi处理 2.安装并配置Nginx 2.1安装 apt-get install nginx (如果安装失败请先升级apt-ge ...

  5. Django 部署到Nginx

    在网上搜了很多篇Django+uwsgi+Nginx的部署文章,忙了一下午头昏脑胀,最终完成了部署.部署文章流程讲解都很好,但在细节上或许缺乏一些注意力,导致我多篇文章来回切换在字里行间寻找蛛丝马迹. ...

  6. [Django笔记] uwsgi + nginx 配置

    django 和 nginx 通过 uwsgi 来处理请求,类似于 nginx + php-fpm + php 安装nginx 略 安装配置uwsgi pip install uwsgi 回想php- ...

  7. 项目部署(ubuntu+uwsgi+nginx+supervisor+django)

    一.在开发机上的准备工作 1. 确认项目没有bug. 2.设置`ALLOW_HOST`为你的域名,以及ip地址. 4.设置`DEBUG=False`,避免如果你的网站产生错误,而将错误信息暴漏给用户. ...

  8. 「Linux+Django」Django+CentOs7+uwsgi+nginx部署网站记录

    转自:http://www.usday.cn/blog/51 部署前的准备: 1. 在本地可以运行的django项目 2. 一台云服务器,这里选用Centos系统 开始部署: 首先在本地导出项目需要的 ...

  9. Django部署--uwsgi配置--nginx服务器配置

    uwsgi.ini文件 [uwsgi] #使用nginx连接时使用,Django程序所在服务器地址 socket=127.0.0.1:8000 #直接做web服务器使用,Django程序所在服务器地址 ...

随机推荐

  1. Python时间性能测量

    主要有以下三种方式: 一,CPU时间 time.clock() 测量CPU时间,比较精准,通过比较程序运行前后的CPU时间差,得出程序运行的CPU时间. 二, 时钟时间 time.time() 测量时 ...

  2. .Net相关

    Lucene 全文搜索 http://lucenenet.apache.org/ Memcached 分布式缓存 http://memcached.org/ selenium UI自动化测试 http ...

  3. 帕雷托最优(Pareto optimality)、帕雷托效率(Pareto efficiency)

    帕雷托最优(英语:Pareto optimality),或帕雷托最适,也称为帕雷托效率(英语:Pareto efficiency),是经济学中的重要概念,并且在博弈论.工程学和社会科学中有着广泛的应用 ...

  4. android之广播(二)

    广播接受者不仅可以通过清单文件来向系统注册,也可以通过代码来注册.并且有的广播必须通过代码来注册广播接受者. 锁屏和解锁广播 电量改变广播 打开屏幕和关闭屏幕 这里将广播接收者写在服务里面 <? ...

  5. JNI系列——PassData

    1.在工程目录下创建xxx.jni包并在该包下创建JNI类 2.在JNI类中声明所有的本地方法,并加载库 3.在MainActivity类中实例化JNI对象,并调用其方法 4.通过Javah生成的方法 ...

  6. HTML5基础知识(3)--required属性

    1.required属性规定在提交之前要填写输入域(不能为空). 2.代码 <body> <form> 账号:<input type="text" r ...

  7. JavaMelody监控SQL

    前言 前面讲过了Javamelody的基本配置,这里简单的介绍下,如何使用Javamelody来监控JDBC以及SQL. 手码不易,转载请注明:xingoo 在网上搜索很多资料,仅有开源社区上的两篇帖 ...

  8. 访问修饰符(public,private,protected,internal,sealed,abstract)

    为了控件C#中的对象的访问权限,定义对象时可以在前面添加修饰符. 修饰符有五种:private(私有的),protected(受保护的),internal(程序集内部的),public(公开的),以及 ...

  9. C# 后台获取WebApi 方法

    以下是方法 返货json数据 代码都有注释 /// <summary>        /// 请求webpapi        /// </summary>        // ...

  10. JQuery 判断浏览器及其版本

    JQuery 中用 方法 jQuery.browser 来判断浏览器,返回值可以为: safari opera msie mozilla. 当然有时候我们还需要区分版本 这就要用到 jQuery.br ...