NGINX+WEB.PY+FASTCGI Service Setup under Windows

Source: Internet
Author: User

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

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.