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!
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
Install django,gunicorn,gevent, install using virtual environment, do not pollute the system library
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
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
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