Django 部署 uwsgi + nginx + supervisor

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

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

更新依赖

  1. pip install uwsgi

编辑配置文件 uwsgi.ini

  1. [uwsgi]
  2. # Django-related settings
  3. chdir = /home/zonghua/Documents/test_project
  4. module = test_project.wsgi:application
  5. env = DJANGO_SETTINGS_MODULE=test_project.settings_production
  6. home = /home/zonghua/Documents/test_project/venv
  7. reload-mercy = 10
  8. user = zonghua
  9. uid = zonghua
  10. pcre-jit
  11. thunder-lock
  12. enable-threads
  13. master = True
  14. threads = 2
  15. processes = 4
  16. socket = 127.0.0.1:8001
  17. chmod-socket = 664
  18. vacuum = true

执行命令

  1. uwsgi --ini uwsgi.ini

运行情况

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

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

  1. server {
  2. listen 80;
  3. charset utf-8;
  4. client_max_body_size 75M;
  5. location /media {
  6. alias /path/to/project/media;
  7. }
  8. location /static {
  9. alias /path/to/project/static;
  10. }
  11. location / {
  12. uwsgi_pass 127.0.0.1:8001;
  13. include uwsgi_params;
  14. }
  15. }

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

  1. [program:test]
  2. directory= /home/zonghua/Documents/test_project
  3. command = /home/zonghua/Documents/test_project/venv/bin/uwsgi --ini /home/zonghua/Documents/test_project/uwsgi.ini
  4. user = zonghua
  5. autostart = true
  6. autorestart = true
  7. stopsignal = QUIT
  8. redirect_stderr = true
  9. loglevel = error
  10. stdout_logfile = /home/zonghua/Documents/test_project/logs/uwsgi_out.log
  11. stderr_logfile = /home/zonghua/Documents/test_project/logs/uwsgi_err.log
  12. 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. NDK开发之javaVM

    1.关于JNIEnv和JavaVM JNIEnv是一个与线程相关的变量,不同线程的JNIEnv彼此独立.JavaVM是虚拟机在JNI层的代表,在一个虚拟机进程中只有一个JavaVM,因此该进程的所有线 ...

  2. 转一篇关于如何在Unity里使用Protobuf

    原帖地址: http://purdyjotut.blogspot.com/2013/10/using-protobuf-in-unity3d.html 先转过来,等时间合适了,再来收拾 Using P ...

  3. 边界网关协议BGP

    Border Gateway Protocol (BGP) is a standardized exterior gateway protocol designed to exchange routi ...

  4. Web服务器磁盘满故障

    问题: 硬盘显示被写满,但是用du -sh /*查看时占用硬盘空间之和还远小于硬盘大小,即找不到硬盘分区是怎么被写满的.今天下午接到同事紧急求助,说生产线服务器硬盘满了.该删的日志都删掉了.可空间还是 ...

  5. Yii 字段验证

    关于验证的属性: $enableClientValidation:是否在客户端验证,也即是否生成前端js验证脚本(如果在form中设置了ajax验证,也会生成这个js脚本). $enableAjaxV ...

  6. android开机自启动广播

    权限<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>     &l ...

  7. BIM软件小技巧:Revit2014所有快捷键汇总表格

    命令 快捷键 路径 修改 MD 创建>选择;  插入>选择; 注释>选择; 视图>选择; 管理>选择; 修改>选择; 建筑>选择; 结构>选择;  系统 ...

  8. iOS开发小技巧--定时器的使用技巧

    一.定时器的使用技巧 -- 定义好了定时器后,添加两个方法,一个是添加定时器的方法,另一个是移除定时器的方法. 使用的时候也要注意,一定先移除之前的timer,然后再添加timer

  9. iOS开发小技巧--iOS8之后的cell自动计算高度

    cell高度自动计算步骤:

  10. hdu2665 && poj2104划分树

    K-th Number Time Limit: 20000MS   Memory Limit: 65536K Total Submissions: 47066   Accepted: 15743 Ca ...