nginx + django windows上部署


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即可訪問!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM