Django到django官网https://www.djangoproject.com/download/下载后,用python包安装方式进行安装
Nginx 使用phpfinder进行安装
Flup到https://pypi.python.org/pypi/flup下载,用python包安装方式进行安装
django请使用1.8版本
(代码)
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;
}
}
前2行时进入django项目目录:
%~d0
cd %~dp0
python manage.py runfcgi host=127.0.0.1 port=8000 protocol=fcgi method=threaded
(1) Nginx配置中location~ ^/static/ {一定要在location ~ ^/ { 前面
(2) 在开发环境中,静态文件(html、css、js、img)只能放在app中的templates文件夹中。但是部署到nginx服务器后,需要把静态文件放到项目目录的static文件夹中