1 Installation Nginx
Download the latest version of Nginx on Windows, http://www.nginx.org/en/download.html.
After decompression can be.
When you run Nginx.exe and you open http://localhost locally, you will see the Welcome page, which proves that Nginx is running well locally, and if the Welcome page does not appear, check that there is a process consuming port 80.
2 installation Flup
Download the corresponding version of Flup, here Download the flup3.x version, suitable for python3.2, download address: HTTPS://GITHUB.COM/CHXANDERS/FLUP3
Decompression (for example, decompression to D:flup)
Install (go to the installation path to Python, and then execute the following command
?
| 1 |
>python setup.py Install |
)
! Note that if you are prompted for missing Setuptools, install distribute-0.6.49.tar.gz, install the method and Flup install the same, download the address: https://pypi.python.org/pypi/distribute/0.6.49
3 Installing MySQL
I'm using the 5.1 version here. Double-click the installation file on the win system to complete the next step. Download Address: http://dev.mysql.com/downloads/
4 Installing the database driver
Download the Python-mysql driver for the PY version on Win and double-click Install. The following download address is 3.2:
Http://files.cnblogs.com/wangqc/distribute-0.6.49.zip
5 Configuring the Server
First you need to modify the Nginx configuration file nginx.conf.
Found it:
?
| 1 2 3 4 |
Location/{root HTML; index index.html index.htm;} |
Add in the inside:
?
| 1 2 3 4 5 6 7 8 9 10 11-12 |
# Host and port to fastcgi server Fastcgi_pass 127.0.0.1:55880; 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; |
Then test the configuration file is correct, in cmd switch to the Nginx installation directory, enter
?
You can start to test the profile, and if the prompt succeeds, the configuration is correct,
It is possible to end all Nginx.exe processes in Task Manager and re-run the Ngin.exe restart Nginx service.
6 Running server.py
Switch to the project directory under CMD, and enter the command
?
| 1 |
Python server.py runfcgi method=threaded host=127.0.0.1 port=55880 |
Attention
This command can only be used to start the project and is not prompted if an error occurs. The following is the correct situation.
Open the http://127.0.0.1:8080 with the browser test, the project is not already running (the first time to run the wait a little longer, please be patient).
7 Some things to note
(1), should first change the place, this everyone should know:
?
| 1 |
debug = Template_debug = false# Set DEBUG to False |
(2), change the allowed_hosts, I am dead on this to forget, my configuration:
?
| 1 2 3 4 |
If DEBUG: #根据DEBUG来确定 allowed_hosts = [""] else:allowed_hosts = ["localhost", "127.0.0.1"] |
(3), the play came, configure Nginx:
There are a lot of related code online, but there's hardly one thing to say:
Configure location ~ ^/static/position, must be in location ~ ^/front, and can not simply use location/static/or location/static, otherwise, static files can not be loaded statically folder!!!
PS: Bring up this, slowly tears ah, is wrong here ...
Too much trouble can be written as batch processing, run the time to double-click on the good.