作者:吉尔伽美什2702933250 | 来源:互联网 | 2023-05-18 18:06
InoticedthatmostofthebooksandtutorialsonDjangomakeitveryclearthatuseDjangodevelopm
I noticed that most of the books and tutorials on Django make it very clear that use Django development server as a normal webserver is not OK. But some state that other webservers are optional, that we can use Django server to put the website on the web for everybody to see.
我注意到Django上的大多数书籍和教程都非常清楚地表明将Django开发服务器用作普通的网络服务器是不行的。但有些人认为其他网络服务器是可选的,我们可以使用Django服务器将网站放在网上供所有人查看。
But why exactly? Why do I need (or not) to use Apache, Lighttpd, Nginx, etc. in front of Django - WSGI?
但为什么呢?为什么我需要(或不)在Django-WSGI前面使用Apache,Lighttpd,Nginx等?
Is Django server not safe in some way? If so, how it is unsafe exactly, and why can't Django just come with a more robust webserver (out of the box, ready to use)?
Django服务器在某种程度上不安全吗?如果是这样,它究竟是不安全的,为什么Django不能只带来更强大的网络服务器(开箱即用,随时可以使用)?
How exactly those webservers help Django? *I know that those webservers have very useful mods, but AGAIN: couldn't Django just come with a safer "mod-able" webserver?
这些网络服务器究竟如何帮助Django? *我知道那些网络服务器有非常有用的mod,但是AGAIN:Django不能带来更安全的“可修改”网络服务器吗?
3 个解决方案
4
It comes down to the goal of the Django project and the efficiency gains associated with re-use (as opposed to reinventing the wheel).
它归结为Django项目的目标以及与重复使用相关的效率提升(而不是重新发明轮子)。
The stated goal for Django is to offer a web application framework that enables quick development and minimal code. The original tagline was a "web application framework for perfectionists with deadlines".
Django的既定目标是提供一个支持快速开发和最少代码的Web应用程序框架。原始标语是“具有最后期限的完美主义者的Web应用程序框架”。
That goal can be accomplished with a simple single-threaded web server that simply facilitates development and testing.
这个目标可以通过一个简单的单线程Web服务器来完成,它简单地促进了开发和测试。
The goal of Apache httpd, Nginx, IIS, etc. on the other hand is to offer exceptionally scalable and performant web servers. These applications are highly configurable as all applications differ and there's no one size fits all. They also require different expertise to design, implement and maintain.
另一方面,Apache httpd,Nginx,IIS等的目标是提供异常可扩展和高性能的Web服务器。这些应用程序具有高度可配置性,因为所有应用程序都有所不同,并且没有一种适合所有应他们还需要不同的专业知识来设计,实施和维护。
So it makes a lot of sense that with limited resources (developer time), the Django team chose to focus on the web-app framework, and leave the production-ready web server to another project.
因此,在资源有限(开发时间)的情况下,Django团队选择专注于Web应用程序框架,并将生产就绪的Web服务器留给另一个项目,这很有意义。