Deployment of DJANGO+NGINX+UWSGI

Source: Internet
Author: User
Tags socket

Prerequisite:

Nginx (>0.8); Uwsgi;django;

Flup Download Address:

wget http://www.saddi.com/software/flup/dist/flup-1.0.2.tar.gz

Installation:

sudo apt-get libxml2-dev Python-dev

Flup and Django are all using Python setup.py install

    Tar zxvf uwsgi-0.9.9.2.tar.gz
    cd uwsgi-0.9.9.2
    make-f makefile.py27 #和你安装PYTHON版本一致
    CP uwsgi/usr/sbin/ Uwsgi

Configuration:

To establish the Project home directory:

    django-admin.py Startproject  My_django

Creating django_wsgi.py in the Django home directory

    Import  os,sys
    import  django.core.handlers.wsgi
    os.environ[' django_settings_module ']= ' My_ Django.settings '   #这里的my_django. Settings represents the "project name. Settings"
    application= Django.core.handlers.wsgi.WSGIHandler ()

To create a uwsgi.xml file under the home directory:

    
  <uwsgi>  
  <socket>0.0.0.0:3001</socket>  
  <listen>20</listen>  
  <master >true</master>  
  <pidfile>/usr/local/nginx/uwsgi.pid</pidfile>  
  <processes>2 </processes>  
  <module>django_wsgi</module>
  <pythonpath>/data/my_django</ pythonpath>  #刚才建立项目的路径
  <profiler>true</profiler>  
  <memory-report>true</ memory-report>  
  <enable-threads>true</enable-threads>  
  <logdate>true</logdate >  
  <limit-as>6048</limit-as>  
  </uwsgi>    

Add Nginx configuration:

server {  
        listen  ;  
        server_name  django.sigh.com.cn;  
        Location/{  
            Root/data/my_django;
            Uwsgi_pass   127.0.0.1:3001;  
            Include     uwsgi_params;  
         }
}

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.