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. 自定义圆形控件RoundImageView并认识一下attr.xml

    今天我们来讲一下有关自定义控件的问题,今天讲的这篇是从布局自定义开始的,难度不大,一看就明白,估计有的同学或者开发者看了说,这种方式多此一举,但是小编我不这么认为,多一种解决方式,就多一种举一反三的学 ...

  2. Apache Tomcat相应插件版本

    参考页面: http://tomcat.apache.org/whichversion.html

  3. js简易日历

    js简易日历中设计的知识点:选项卡切换   数组    innerHTML  连接符 与选项卡的区别:div的个数不同 连接符中需要注意的:(优先级) "abc"+12+3+&qu ...

  4. Ubuntu下tftp服务器的搭建

    参考博客:http://blog.chinaunix.net/uid-26495963-id-3206829.html 1. 安装 $ apt-get install tftp-hpa tftpd-h ...

  5. 【BZOJ 4455】【UOJ #185】【ZJOI 2016】小星星

    http://www.lydsy.com/JudgeOnline/problem.php?id=4455 http://uoj.ac/problem/185 有一个$O(n^n)$的暴力,放宽限制可以 ...

  6. 犀牛书的实例代码:给对象添加freeze, hide, 查询descriptors

    /* * Define a properties() method in Object.prototype that returns an * object representing the name ...

  7. mysql-查看全局变量设置

    show global variables like '%sql_mode%' 全局变量

  8. Android消息机制之ThreadLocal的工作原理

    来源: http://blog.csdn.net/singwhatiwanna/article/details/48350919 很多人认为Handler的作用是更新UI,这说的的确没错,但是更新UI ...

  9. [Linux.NET] CentOS 开启/关闭端口

    最近一直在学习研究mvc网站部署到Linux上,Web服务器用的Jexus,linux版本是阿里云提供的centos.一个服务器又要放多个独立网站,对于学习阶段使用多个端口标识还是挺方便的,本文记录下 ...

  10. JDBC简介及编码步骤

    一.什么是JDBC JDBC(Java Data Base Connectivity,java数据库连接)是一种用于执行SQL语句的Java API,可以为多种关系数据库提供统一访问,它由一组用Jav ...