Django+nginx+flup deployment

Source: Internet
Author: User
Tags nginx server
1. Django, Nginx, Flup installation

Django to the Django official website https://www.djangoproject.com/download/download, install using Python package installation method

Nginx Use Phpfinder for installation

Flup to Https://pypi.python.org/pypi/flup download, install with Python package


Django Please use version 1.8

2. Modify the Nginx configuration file

Code

server {

Listen 80;

server_name auto.apitest.com;

Index index.phpindex.html index.htm;

Location ~ ^/static/{

Root e:/project/apitestvision;

Expires 30d;

Break

}

Location ~ ^/{

Fastcgi_pass 127.0.0.1:8000;

#fastcgi_index index.html

Fastcgi_param Path_info$fastcgi_script_name;

Fastcgi_param Request_method$request_method;

Fastcgi_param query_string$query_string;

Fastcgi_param Content_type$content_type;

Fastcgi_param content_length$content_length;

Fastcgi_param Server_protocol$server_protocol;

Fastcgi_param Server_port$server_port;

Fastcgi_param Server_name$server_name;

Fastcgi_pass_header Authorization;

Fastcgi_intercept_errors off;

}

}

3. Running the Django Project

First 2 rows into the Django project directory:

%~d0

CD%~dp0

Python manage.py runfcgi host=127.0.0.1 port=8000 protocol=fcgi method=threaded

4. Matters needing attention

(1) nginx configuration location~ ^/static/{must be in location ~ ^/{Front

(2) In the development environment, static files (HTML, CSS, JS, img) can only be placed in the Templates folder in the app. However, after deploying to the Nginx server, you need to put the static files in the static folder of the project directory

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.