Django+nginx+supervisor+gunicorn+gevent Site Deployment

Source: Internet
Author: User
Tags django website install django virtual environment

Django+nginx+supervisor+gunicorn+gevent Site Deployment

Django,nginx,supervisor,gunicorn,gevent These are the most famous software in the field, the following deployment is in the ubuntu12.04 inside the verification of success!

  1. The first is to install these software under Ubuntu is relatively simple, nginx and supservisor installation is as follows

    Apt-get Install Nginx,supervisor

    Using Python under Ubuntu, it is highly recommended to install Python-dev

    Apt-get Install Python-dev
  2. Install django,gunicorn,gevent, install using virtual environment, do not pollute the system library

  3. Configure Gunicorn

    Gunicorn app.wsgi:application-w 4-b:% (proxy_port) s-k gevent--max-requests $--access-logfile=% (access_log) s--erro r-logfile=% (Error_log) s

    This is a basic run configuration, but it's enough for most websites

  4. Supervisor Configuration

    [program:dyzww]autorestart=truecommand= here writes the Gunicorn commanddirectory= site in the directory process_name= top shows the process name redirect_ Stderr=truestdot_logfile=log file
  5. Nginx Configuration

    server {  Listen-default;  server_name _;  Default_type Application/octet-stream;  gzip on;  Gzip_http_version 1.0;  Gzip_proxied any;  Gzip_min_length;  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 static file directory, trailing slash must be/;  }  location/media/{    alias media file directory, trailing slash must have/;    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 here to fill in the Gunicorn listening address;  }  Access_log log file;}

According to the above configuration, the Django website can be driven up, static files are all handled by Nginx, only the dynamic file needs Django processing, which greatly increased performance! Small station easy to read Chinese network is so driven, the above code all copied from the server! Here also give a small station advertising http://www.ydzww.com,

    • This article is from: Linux Learning Network

Django+nginx+supervisor+gunicorn+gevent Site Deployment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.