Web.py running on the nginx uwsgi

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

Beginner web.py, must be run in nginx only, also know the performance of uwsgi is optimal, so this paper will record how to build such an environment.

Installing nginx 1

In many ways, the general source installation

Installing uwsgi 2

Download the source code, I am here to download: http://projects.unbit.it/downloads/uwsgi-1.9.20.tar.gz

After decompression operation Python setup.py install can be

Installing web.py 3

A class of like, download address;: http://projects.unbit.it/downloads/uwsgi-1.9.20.tar.gz

After extracting the python setup.py install

4 the configuration of nginx, the access to the uwsgi for processing: add the following configuration in nginx.conf, the 8000 port access all over to uwsgi treatment, uwsgi port 9000 is occupied

    server {
        listen       8000;

        location / {
            include   uwsgi_params;
            uwsgi_pass  127.0.0.1:9000;
        }
    }

5 to write a web.py program, named code.py, to handle the real request

import web

# Root requests are submitted to the index processing
urls = ('/', 'index')

# The index class, only to return a hello world
class index:
        def GET(self):
                return "Hello, world!"


app = web.application(urls, globals())
application = app.wsgifunc()

6 start uwsgi

#  uwsgi -s 127.0.0.1:9000 -w code
-s IP and port number

-w specifies the application name

The problem is that if the increased if __name__ = = " applications; __main__": code, will report "unable to load app 0" error, it is not known how to solve

7 the resumption of the nginx, enter "host:8000" in a browser, you can see "Hello, world! " echo in the browser


Reference resources

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Lyndon at March 05, 2014 - 1:01 PM