[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Lies in education [was Re: The "loop and a half"]

On 2017-10-12, Ben Bacarisse <ben.usenet at bsb.me.uk> wrote:
> Chris Angelico <rosuav at gmail.com> writes:
>> Normally, with a Python-based framework, you don't need _any_ web
>> server configuration. You simply define your URL routing within the
>> Python code. The only thing the web server needs to know is where to
>> find the web app, and that's sufficiently standard that it can be done
>> off-the-shelf; for instance, you push your code to Heroku, and they
>> set everything up to pass requests to your app. Not possible with PHP,
>> since you need *custom* web server config to manage your rewrite
>> rules.
> That's at odds with what I've read online which admittedly may be all
> junk.  I wanted to try Flask so I installed the Ubuntu packages but then
> got stuck on a huge document that suggested I needed to install things
> called Nginx and Gunicorn.  You've now mentioned another: Heroku.  I'm
> sure the complex instructions I found are not really required -- it was
> probably just the usual "this is what I did so this is how it's done"
> document, but I'm having trouble finding the simpler way to do it.
> Since no web server configuration is needed (I have a working Apache
> installation that mirrors, as closely as possible, what my hosting
> provider uses) it should be relatively easy.  Can you tell me, or can
> you point me to a resource that tells me, where to put the app?  I don't
> yet know what "push your code to Heroku" means.

"don't need _any_ web server configuration" is rather, er, optimistic.
For Apache you'd need the mod_proxy_uwsgi module installed, and the
config would be something like this:

    DocumentRoot /srv/www/appname/appname
    <Location />
        ProxyPass uwsgi://
    <Location /static/>
        ProxyPass !

and you need an app container listening on the port defined above,
e.g. uwsgi with config like:


    plugin = python3
    socket =
    threads = 4
    master = 1
    chdir = /srv/www/appname
    module = appname:app
    # https://github.com/unbit/uwsgi/issues/1126
    wsgi-disable-file-wrapper = true

and you'll need something to run uwsgi on system startup.