[Flask] Deploying Flask on Debian

Alex Hall ahall at autodist.com
Thu May 5 12:30:22 EDT 2016


Hey all,
Here's where I am on this journey. I spent the last day or so stuck on
getting my database and Debian server to talk. I FINALLY got that to work
just now, and my Flask app is able to start up. It seems the Flask server
can't serve to external web browsers, only those able to access localhost,
but I'm trusting that the app will now work as expected.

I've got Nginx installed and, it claims, starting up normally. I've
installed WSGI and UWSGI, and my Flask app is in a virtual environment,
which I can activate successfully. At last, I'm ready for the actual
configuration of the pieces to let Nginx serve Flask. Which leads to a
couple questions, for clarification.

1. Is Mod_WSGI only for Apache? Should I stick with UWSGI, given that I'm
using Nginx?

2. I read that UWSGI is also a web server, and that it's suggested to use
UWSGI with Nginx behind it. This seems more complicated than I expected.
Did I understand it right? Is this a choice, or the only/best way to set
things up?

3. When all this is up and running, will views be relative to my app, or
app/templates? That is, should I set the document root in Nginx to be
/var/www/myApp, or /var/www/myApp/templates? The myApp folder has run.py,
config.py, static/, and templates/.

On Wed, May 4, 2016 at 3:44 AM, Andrea D'Amore <and.damore at gmail.com> wrote:

> On 4 May 2016 at 00:02, Alex Hall <ahall at autodist.com> wrote:
> > Thanks guys. I'm intrigued by Nginx, after reading more about it. The
> > problem is that apt-get install nginx keeps failing, with some kind of
> > dependency problem, sudo or no sudo.
>
> That's odd for a freshly installed Jessie, it could be a clash with
> the installed apache service but since you didn't paste the actual APT
> error there's no way to tell.
>
> > I've stopped Apache, but still get the
> > error. Thus, I'd like to stick to Apache if I could, simply because it's
> > already installed and (to my knowledge) working.
>
> I stay away from apache httpd as much as I can, for a similar need I
> use lighttpd as proxy to the flask application on localhost.
>
> > This is a small, internal
> > site that doesn't need the efficiency of Nginx to run, and I'm having
> enough
> > problems with getting Flask to work that messing with installing a
> stubborn
> > Nginx doesn't seem the best way to stay sane.
>
> uwsgi is capable of directly serving the app, if it's a LAN app you're
> probably fine deploying the app with it, for a very low number of
> clients you could even use the builtin server.
> Just the other day I was reading again about flask deployment and I
> think I saw numbers as rule of thumb, 10 clients for builtin server
> and 100 for uwsgi IIRC but I may as well just making those up.
>
> If you decide to go with uwsgi, that I'd suggest in this case, just
> follow its documentation, it's detailed and got plenty of examples. If
> you want another process to serve TCP 80 remember to shut down the
> apache service.
>
>
> --
> Andrea
>



-- 
Alex Hall
Automatic Distributors, IT department
ahall at autodist.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20160505/29951e98/attachment.html>


More information about the Flask mailing list