On Fri, Jun 1, 2012 at 11:47 PM, Shannon Cruey <
shannon.cr...@cloudsidekick.com> wrote:

> OK, now this is just getting weird.  Has anyone set up their web.py
> application using wsgi on nginx?  I havent even started trying yet because
> I just don't understand.
>
> As far as I can tell, nginx is pretty easy.  I have it up and running,
> giving me it's home page.
>
> Here's where it gets confusing... the evidently many meanings of "uwsgi".
>
>    1. nginx has a build in module called uwsgi.  *
>    http://wiki.nginx.org/HttpUwsgiModule* (This page warns that this
>    module is different than the *uWSGI server*.)
>    2. There is a server (apparently stands alone) called uWSGI.*
>    http://projects.unbit.it/uwsgi/*
>    3. a web.py cookbook *http://webpy.org/cookbook/mod_wsgi-nginx* talks
>    about mod_wsgi in nginx, which apparently isn't a standard module and must
>    be compiled on the target platform (yuck)
>
> There are even more confusing options out there, like using fast-cgi
> instead, the list goes on...
>
> This is all so very confusing.  Here's what I require, and I'm asking for
> advice.
>
>    1. This is a production application - the main reason why I'm not
>    using the builtin server.
>    2. I've been "encouraged" to use nginx instead of apache, but it's not
>    required.
>    3. What is required is a clean, simple and repeatable install
>    process.  (these environments are in the cloud, so they will be stood up
>    and torn down often.  I really can't afford messing around with having to
>    compile, install stuff that isn't easily done with apt-get, etc. The
>    install process on a vanilla ubuntu server must be do-able with a single
>    script, and (yes I'm about to say it) ... be foolproof.)  Some things in
>    life "just work."  Installing this must "just work."
>
>
> So, in everyones opinion ... what's the best, clean and simple way to take
> my web.py application and serve it with a rock solid web server?
>

uwsgi is swiss-army-knife of web apps. It can work in so many different
ways. One easiest way get started is running it as a http server and expose
it via nginx using mod_proxy. (This may not be the best approach, but
surely the easiest to get started.)

# python code, say hello.py
import web

urls = (
    '/', 'hello'
)
app = web.application(urls, globals())

class hello:
    def GET(self):
        return 'Hello, world!\n'


# uwsgi expects a variable with name `application`
application = app.wsgifunc()

if __name__ == "__main__":
    app.run()

Now run uwsgi server.

$ uwsgi -H ~/pyenvs/sandbox --http 127.0.0.1:8080  --wsgi hello -p4

I'm using a virtualenv here and I've specified that with -H option. (if you
are not using virtualenv, I strongly recommend you to use it).

--wsgi option specified the wsgi module name, -p4 indicates that we want to
run 4 workers.

--http indicates that we want to run uwsgi as a http server.

Now you can configure nginx to proxy this server.

If you want to run uwsgi as fastcgi-server, use --fastcgi-socket instead of
--http.

If you've nginx server is configured with uwsgi support, then you can
specify --socket to make it speak its default custom protocol.

Anand

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to webpy@googlegroups.com.
To unsubscribe from this group, send email to 
webpy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to