[Flask] Deploying Flask on Debian

Alex Hall ahall at autodist.com
Thu May 5 13:56:21 EDT 2016


Thanks for the answers!

At the risk of going a bit off topic, I made my Nginx and UWSGI
configuration files according to this guide:
http://www.markjberger.com/flask-with-virtualenv-uwsgi-nginx/

But am now seeing both applications fail to start. They offer only "See
systemctl status or journalctl" as a way to view the problem, but those
just tell me there was an exit code of 1. There's no "error in this file on
this line" or anything helpful. Is there a way to see exactly what's wrong?
I know it'll be some small syntax problem in one of the files, since I had
to write them by hand over SSH rather than pasting.

On Thu, May 5, 2016 at 1:30 PM, Anthony Ford <ford.anthonyj at gmail.com>
wrote:

> Hey Alex,
>
> Congrats on the progress so far. Let me see if I can clarify some things
> for you
>
> 1. Is Mod_WSGI only for Apache? Should I stick with UWSGI, given that I'm
>> using Nginx?
>>
>
> Yes. Mod_WSGI is essentially a router that passes the request from Apache
> (the url requested, HTTP headers,  etc), and will accept the response from
> your app and pass it back to Apache to send to the client. If you are using
> Nginx, yes you should stick with uWSGI.
>
>
>
>> 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?
>>
>
> uWSGI can act as a standalone web-server for HTTP/S (
> http://uwsgi-docs.readthedocs.io/en/latest/HTTP.html#the-uwsgi-http-https-router).
> If you have a heavy site (i.e. hundreds+ of active users), you will waste
> efficiency and capacity by having uWSGI handle your static files (i.e. your
> JS, images, etc.), so it is recommended to hide uWSGI behind an HTTP server
> (i.e. Nginx) and let it handle the static loads since they are
> significantly better at serving static files.
>
> No, you do not have to do this if you are building an internal or low use
> site (but if the site is public, be prepared for traffic spikes that can
> bring your site down, like slash-doting or reddit hug-of-deaths). Use the
> `--http` option as suggesting in the above link.
>
>
>
>> 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/.
>
>
> If you are serving your app behind Nginx, the main document root (or
> location in nginx parlance), i.e. /, would be your app in wsgi (the
> uwsgi_pass section). The only thing Nginx should serve would be your static
> files in `static/` (which should be served as `/static/`.
>
> I've stuck together a gist with some sanitized config files from a recent
> project. You can find them here:
> https://gist.github.com/ajford/32ca09c1bdb67e2211247f189aa2ae9a
>
> It's got some complexity (the vars in the wsgi definitions) because this
> was running on an applications server with three different Flask based apps
> running behind Nginx. In my case, while the number of users was low (~10
> max, more like a single user concurrent), I only had the one server
> available, so they were placed behind Nginx to handle the virtual server
> names (so the different apps wouldn't crash when serving). This may be
> possible using uwsgi stand-alone, but I already knew how to do it in Nginx.
>
> Hope this helps!
>
>
>
> Anthony Ford,
> KF5IBN,
> ford.anthonyj at gmail.com
>



-- 
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/387b75c7/attachment.html>


More information about the Flask mailing list