简体   繁体   English

Django应用-在virtualenv与系统范围内应安装什么?

[英]Django app - What do I install in virtualenv vs system wide?

I'm working on creating my first "real" web app using Django. 我正在使用Django创建我的第一个“真实” Web应用程序。

Yesterday I learned I should be using a web server like Nginx to serve static files and pass off requests for dynamic content to my web app. 昨天我了解到我应该使用Nginx这样的网络服务器来提供静态文件,并将对动态内容的请求传递给我的Web应用程序。 I also learned that I need something like Gunicorn as the intermediary between the web server (Nginx) and my Django app. 我还了解到,我需要像Gunicorn这样的东西作为Web服务器(Nginx)和Django应用之间的中介。

My question is about virtualenv. 我的问题是关于virtualenv。 It makes sense that we would contain app related software in it's own separate environment. 在我们自己的独立环境中包含与应用程序相关的软件是很有意义的。 What should I install in virtualenv, and what gets installed system wide? 我应该在virtualenv中安装什么,在系统范围内安装什么? For example, in this guide we seem to install Python, Nginx and the database system wide (because they're installed before virtualenv is installed) while Django and Gunicorn are installed in virtualenv. 例如,在本指南中,我们似乎安装了Python,Nginx和整个数据库系统(因为它们是在安装virtualenv之前安装的),而Django和Gunicorn则安装在virtualenv中。 It makes sense that Gunicorn would have to go in the virtualenv since its importing our python app, as explained here . 这是有道理的,Gunicorn将不得不因为它的进口我们的Python应用程序的virtualenv中去,为解释在这里 Are the other things required to be installed system wide? 是否需要在系统范围内安装其他产品? Or can I pick either way? 还是我可以选择其中一种? Is one way preferred over another? 一种方法优先于另一种方法吗?

Thanks! 谢谢!

Virtualenv is for managing Python libraries. Virtualenv用于管理Python库。 It is not for managing Python itself, or for external services such as databases; 它不是用于管理Python本身,也不是用于数据库等外部服务; it does however manage the Python libraries you use to access the database. 但是,它确实管理用于访问数据库的Python库。

There's no room for confusion here, because there's simply no way to install Python itself or a database within a virtualenv. 这里没有混淆的余地,因为根本没有办法在virtualenv中安装Python本身或数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM