Nginx + Django on Windows

Source: Internet
Author: User

It ' s quite simple-to-run Django on Windows. Here is some key steps to follow-

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.htmlFastcgi_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 ports, 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.

^/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.

runfcgi host=127.0.0.1 port=8001method=threaded

7. It ' s done, open a browser, and try http://127.0.0.1:8000

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.