Before the construction, it is necessary to understand what is fastcgi, but in view of my own also do not know, here do not move the door axe, please refer to the various encyclopedia and official website information.
1. Download Resources
Python: Poke here
Webpy: Poke Here
Flup: Poke Here
Nginx: Poke Here
It is recommended that you install Python first, then load Setuptools,easy_install, and then use the Easy_install command to download the installation Web.py,flup directly.
Nginx Download decompression can be used, but need to configure a little bit.
2.nginx Configuration
After the installation is complete, it is OK to open nginx.exe and then access the index.html content under the HTML of the localhost display folder.
Conf under the nginx.conf is its configuration file, this thing is a lot of parameters, configuration parameters can refer to this article, and the configuration before you remember to leave the backup AH
What we need to change now is as follows.
server { listen ; server_name www.xspython.com; Location/{ root "D:\Project\Python\web"; Index index.html index.htm; Include Fastcgi_params; Fastcgi_param script_filename $fastcgi _script_name; Fastcgi_param path_info $fastcgi _script_name; Fastcgi_pass 127.0.0.1:8008; }}
Use the command line when you are finished setting up
Nginx–s Stop Stop Service
Nginx–t test configuration file for errors
Nginx Start-up service
Then visit localhost, which will show the index.html under pyweb/www/(write a Hello World yourself)
3.web.py
Create a new code.py file with the following contents
Import Weburls = ( '/', ' Index ', '/list ', ' list ',) class index: def GET (self): return "Hello, world123456! " Class list: def GET (self): return "Hello, list!" if __name__ = = "__main__": app = web.application (URLs, Globals ()) App.run ()
Then the command line launches it, like this Python code.py 8008 fastcgi, where the port number is set in the 8008 second step configuration file, which is not normally accessible if inconsistent.
Now visit Localhost/hello, see if it returns Hello, world?
Now visit www.xspython.com, see if it returns Hello, world?
NGINX+WEB.PY+FASTCGI Service Setup under Windows