標籤:
nginx工作原理:
nginx用於處理靜態檔案,動態部分經由fastcgi 、scgi或uwsgi交給django處理!
1、在網站目錄下執行:manage.py runfcgi host=127.0.0.1 port=8051 protocol=fcgi method=threaded
2、在D:\nginx-1.7.10下執行:nginx.exe
nginx.conf:
server {
listen 8080;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
# host and port to fastcgi server
ssi on;
ssi_silent_errors on;
ssi_types text/shtml;
fastcgi_pass localhost:8051; #用於和django交換資料的連接埠, 在執行"manage.py runfcgi host=127.0.0.1 port=8051 protocol=fcgi method=threaded" 連接埠號碼要一致
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass_header Authorization;
fastcgi_intercept_errors off;
}
}
3、在瀏覽器中輸入http://localhost:8080即可訪問!
nginx + django windows上部署