nginx + django windows上部署

來源:互聯網
上載者:User

標籤:

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上部署

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.