Deploying Flask Apps to Production Linux Servers using Gunicorn and Nginx

This is is going to be a super short post that I’m really just writing for my own personal reference. The old guides that I used to use to setup my linux virtual machines for my flask apps keep giving me problems, so the purpose of this post is to jot down how to do this in the future the next time I need to do this.

First, reference this blog post: Deploy Flask The Easy Way With Gunicorn and Nginx!

What I like about this particular blog post is it skips all of the complicated pain in the @$$ steps like setting up non-root users and whatnot. I think using root is fine for small projects.

Last, the most critical thing is to make sure you install gunicorn into your virtual environment. When you do this, make sure to set the –ignore-installed flag so that gunicorn gets installed into the virtual environment. I believe this is the missing step from the previous guides I used to use which kept causing my setups to fail.

(venv) $ pip install --ignore-installed gunicorn

If you are installing from requirements.txt, also make sure to set the –ignore-installed flag so that gunicorn gets installed into your virtual environment instead of somewhere else:

(venv) $ pip install --ignore-installed -r requirements.txt

 

topherPedersen