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