Reputation: 4135
Seems like a simple question but I cannot find it addressed anywhere. Every tutorial I look at does things slightly differently, and I'm pretty sure I've seen it done both ways.
In my development environment, python, flask, and all other dependencies of my application go inside the Virtual Environment.
When configuring a production environment, do Nginx and uWSGI go inside the virtual environment?
Thanks!
Upvotes: 3
Views: 1063
Reputation: 16029
First of all, Nginx never goes in Virtualenv. It is a os service and has nothing to do with python. It only serves webrequests and knows how to pass them to a upstream service (like uwsgi).
Second; don't put things in virtualenv that don't need seperate versions. Uwsgi is quite stable now, so you will almost never need separate versions; so don't put it in venv.
Third; when you plan for production deployment, keep things as simple as possible. Any added complexity will only make the chance of failure higher. So do not put venv on your prod servers until your absolutely need it. And even then you are probably putting to much stuff on that server. Keep your servers single minded. I find it easier to use multiple machines (especially with cloud services like AWS) that each have one purpose than to cram everything on one big machine (where one screwball process can eat all the mem for everybody else)
Forth; When you do need more python projects/services it is better to separate them with things like docker, since then they are better maintainable and better isolated from the rest.
Upvotes: 3