django+nginx+supervisor+gunicorn+gevent 网站部署

django,nginx,supervisor,gunicorn,gevent这几个都是在本领域大名鼎鼎的软件,下面的部署都是在ubuntu12.04里面验证成功的!

  1. 首先是安装这些软件在ubuntu下面都比较简单,nginx和supservisor的安装如下

    apt-get install nginx,supervisor

    在ubuntu下使用python,强烈建议安装python-dev

    apt-get install python-dev
  2. 安装django,gunicorn,gevent,使用虚拟环境安装,不要污染了系统库

  3. 配置gunicorn

    gunicorn app.wsgi:application -w 4 -b :%(proxy_port)s -k gevent --max-requests 500 --access-logfile=%(access_log)s --error-logfile=%(error_log)s

    这个是一个基本的运行配置,不过对于大多数网站来说已经够用了

  4. supervisor配置

    [program:dyzww]
    autorestart=true
    command= 这里写上面gunicorn 的command
    directory= 网站所在的目录
    process_name= top 中显示的进程名
    redirect_stderr=true
    stdot_logfile=log文件
  5. nginx配置

    server {
    listen 80 default;
    server_name _;
    default_type application/octet-stream;
    gzip on;
    gzip_http_version 1.0;
    gzip_proxied any;
    gzip_min_length 500;
    gzip_disable "MSIE [1-6]\.";
    gzip_types text/plain text/html text/xml text/css
    text/comma-separated-values
    text/javascript application/x-javascript
    application/atom+xml image/jpeg image/gif image/png; location /static/ {
    alias 静态文件目录,后面的斜杠必须要/; } location /media/ {
    alias 媒体文件目录,后面斜杠必须有/;
    expires 30d;
    } location / {
    try_files $uri @proxied;
    } location @proxied {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass 这里填写gunicorn监听的地址;
    } access_log log文件;
    }

按照上面的配置,django网站就能够驱动起来了,静态文件全部由nginx处理,只有动态文件需要django处理,这样大大的增加了性能!小站易读中文网就是这么驱动的,上面的代码全部从服务器中copy过来! 在这里也给小站打个广告 http://www.ydzww.com

大家要是觉得本文写的对你有一点点帮助,您转载的时候保留一下小站的地址,举手之劳,有疑问的话 yiduzww@126.com 发邮件给我!

django+nginx+supervisor+gunicorn+gevent 网站部署的更多相关文章

  1. Flask+Nginx+Supervisor+Gunicorn+HTTPS部署教程(CentOs)

    写在前面 之前的文章中,我们详细讲述了怎样安装 Nginx,Python,Supervisor,Gunicorn,HTTPS.经本人多次测试是完全可以跑通的,那么本篇将介绍怎样将这些组合起来运行一个H ...

  2. CentOS7中配置基于Nginx+Supervisor+Gunicorn的Flask项目

    配置Nginx 1.安装nginx yum install nginx 2.安装好后在/etc/nginx/default.d中添加location的配置,并指向8001端口,以后Gunicorn会监 ...

  3. nginx+supervisor+gunicorn+flask

    一. 更新系统 #yum -y install epel-release #yum clean all && yum makecache #yum -y update 二.安装pyth ...

  4. django+nginx+uwsgi的生产环境部署(Ubuntu16.04)

    一,准备工作: 代码一定要能本地跑起来! 各种基础包的安装略默认已经安装python3,nginx,uwsgi等基础依赖,注意版本问题. 本地setting.py文件修改如下(改为生产模式,把debu ...

  5. ASP.NET Core Docker Nginx分权,多网站部署

    https://www.cnblogs.com/esofar/p/10694319.html

  6. apache(nginx)+django+virutalenv(virtualenvwrapper)+gunicorn+supervisor配置高效web环境

    前言 django的调试模式配置简单,用于测试十分方便,但众所周知,这个只适合于调试,生产上运行效率十分低下. 后来考虑用nginx+uwsgi的模式进行,但之前配置过apache+wsgi的方式,感 ...

  7. 使用 Nginx 和 Gunicorn 部署 Django 博客(转)

    原文:http://zmrenwu.com/post/20/  http://www.siar.me/post/9/ 针对很多朋友反映按照教程的做法始终只能看到 Nginx 欢迎页面的问题,Tian ...

  8. Nginx 和 Gunicorn 部署 Django项目

    目录 Nginx 和 Gunicorn 部署 Django项目 配置Nginx 安装配置Gunicorn 通过命令行直接启动 Gunicorn 与 uwsgi 的区别,用哪个好呢 Gunicorn u ...

  9. Django 部署 uwsgi + nginx + supervisor

    Django 部署 uwsgi + nginx + supervisor https://hacpai.com/article/1460607620615?p=1&m=0 zonghua • ...

随机推荐

  1. CodeForces 591B

    题目链接: http://codeforces.com/problemset/problem/591/B 题意: 给你一串字符串,字符串里的字符全是a-z的小写字母,下面的m行,是字符串的交换方式, ...

  2. QQ互联 回调地址

    http://wiki.connect.qq.com/%E5%9B%9E%E8%B0%83%E5%9C%B0%E5%9D%80%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98% ...

  3. Apache-Tika解析Excell文档

    通常在使用爬虫时,爬取到网上的文章都是各式各样的格式处理起来比较麻烦,这里我们使用Apache-Tika来处理Excell格式的文章,如下: package com.mengyao.tika.app; ...

  4. O - Extended Traffic(判断负环)

    题意:有n个城市,每一个城市有一个拥挤度ai,从一个城市I到另一个城市J的时间为:(aJ-aI)^3,存在负环.问从第一个城市到达第k个城市所话的时间,如果不能到达,或者时间小于3输出?否则输出所花的 ...

  5. java 吞吐量

    jvm中 ,执行用户的代码占 的时间/总时间 ,假如前者是99 分钟,后者一分钟,则吞吐量为99% ,吞吐量越大.系统越好,如何设计系统,导致系统吞吐量高,因为我们知道,垃圾回收,7种垃圾收集器,也不 ...

  6. android market 选择

    通过Java包名直接定位到你的App http://market.android.com/details?id=<java包名>或者market://details?id=<java ...

  7. [PWA] 15. Using The IDB Cache And Display Entries

    We want to use IDB to store the wittr messages. The logic is when the page start: service worker wil ...

  8. MYSQL 体系结构图-LRU

  9. [转] C++虚函数与虚函数表

    http://www.cnblogs.com/Ripper-Y/archive/2012/05/15/2501930.html http://blog.csdn.net/haoel/article/d ...

  10. instanceof 和 构造函数

    1. intanceof 运算符 instanceof 运算符返回一个布尔值,表示指定对象是否为某个构造函数的实例. instanceof左边是实例对象 右边是构造函数.它的运算实质是检查右边构建函数 ...