nginx + django on windows
1. Download nginx/windows from http://nginx.org/en/download.html
2. Unzip the pckage (like nginx-1.7.2.zip) to a folder in your machine)
3. Install flup (fastcgi connecting nginx and django) from https://pypi.python.org/pypi/flup
4. Configure nginx config file. Some key section is shown below,
server {
listen 8000;
server_name localhost;
location ~ ^/ {
fastcgi_pass 127.0.0.1:8001;
#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;
}
}
Nginx would listen on 8000 port, and when you access the django site, it would pass the request to your django application listening on 8001 port.
Also add the following section to the conf file to tell nginx to render static files in your django application.
location ~ ^/static/ {
root "C:/Users/yufa/Desktop/Document/Study/Django/sqlmonitor/";
expires 30d;
# root html;
# index index.html index.htm;
break;
}
5. Start nginx (nginx.exe)
6. Start django, binding to nginx.
python manage.py runfcgi host=127.0.0.1 port=8001 protocol=fcgi method=threaded
7. It's done, open a browser, and try http://127.0.0.1:8000
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.