单独的服务器来服务 django 应用程序及其内容?
我对如何继续感到有点困惑。我正在将 Django 设置为在 Mediatemple DV 服务器上运行。我正在尝试找出提供图像/视频/等内容的适当设置。
我不太明白这在 http://docs.djangoproject 上意味着什么。 com/en/dev/howto/deployment/modwsgi/
我们建议使用单独的 Web 服务器(即不运行 Django 的服务器)来提供媒体服务。这里有一些不错的选择:
lighttpd, nginx, 无尾礼服, Apache 的精简版, 切诺基
这是否意味着我应该在一个 Apache 实例上(通过 mod_wsgi)为 Django 提供服务,然后在另一个 Apache 实例或上述替代方案之一上提供其内容?我可以在同一个专用虚拟服务器上执行此操作,对吧?如果是这样,我应该如何做有什么建议吗?
谢谢!
I'm a little confused as to how to proceed. I'm setting up Django to run on a Mediatemple DV server. I'm trying to figure out the appropriate setup for serving image/video/etc content.
I don't quite understand what this means on http://docs.djangoproject.com/en/dev/howto/deployment/modwsgi/
We recommend using a separate Web server -- i.e., one that's not also running Django -- for serving media. Here are some good choices:
lighttpd,
Nginx,
TUX,
A stripped-down version of Apache,
Cherokee
Does this mean I should serve Django on one Apache instance (via mod_wsgi) and then serve its content on another instance of Apache or one of the alternatives above? I can do this on the same dedicated virtual server, right? If so, any advice on how I should do that?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于大多数人来说,不需要单独的媒体服务器。人们越来越多地批评 Django 文档在没有必要的情况下过于自由地推动人们朝这个方向发展。
因此,一开始不要打扰,如果使用 mod_wsgi,也可以使用 Apache Web 服务器来处理静态媒体。不过,建议您确保在 mod_wsgi 的守护进程模式下运行 WSGI 应用程序,因为这样,提供静态文件的进程将会很小,并且不会产生实际动态 Web 应用程序的开销。
如果过于担心内存使用情况,还可以阅读:
http://blog.dscpl.com.au/2009/11/save-on-memory-with-modwsgi-30.html
看看这一切是如何进行的,只有当 Apache 本身不这样做时足够了,然后考虑使用另一台服务器来处理媒体,首选的安排是使用 nginx 来处理静态媒体,nginx 还充当 Apache/mod_wsgi 的代理。在前面使用 nginx 实际上可以让 Apache/mod_wsgi 执行得更好,而在单独的域上使用 nginx 则不会。
For the majority of people there is no need for a separate media server. There has been growing criticism over the Django documentation being too liberal in pushing people in that direction when there is no need.
So, don't bother initially and if using mod_wsgi use the the Apache web server for static media as well. It is recommended though that you ensure your run your WSGI application in daemon mode of mod_wsgi as that way the processes serving up static files will be slim and not incur overhead of the actual dynamic web application.
If overly worried about memory usage, also have a read of:
http://blog.dscpl.com.au/2009/11/save-on-memory-with-modwsgi-30.html
See how that all goes and only when Apache itself looks not to be enough, then look to using another server to handle media, the preferred arrangement being to use nginx to handle static media, with nginx also acting as proxy through to Apache/mod_wsgi. Using nginx in front actually allows Apache/mod_wsgi to perform better, which using nginx on a separate domain will not.
基本上它的意思是,您应该使用 apache 和 mod_wsgi 来为您的 django 应用程序提供服务,并使用更轻量级的 Web 服务器(如 nginx)来提供您的静态内容。
例如。
www.yourapp.com ->阿帕奇-> mod_wsgi->你的 Django 应用程序
static.yourapp.com -> nginx
通过分离您的关注点,您可以将 apache 实例配置为处理繁重处理的自卸车,并将 nginx 服务器配置为像赛车一样轻量且快速,提供大量静态文件。
如果您配置 nginx 使其处理所有 Web 流量,则可以将所有 django 请求反向代理到其后面的 apache,并拦截所有静态文件并从 nginx 提供这些海峡。
请参阅这些链接以获取更多信息。
http://codespatter.com/2009 /04/23/how-to-speed-up-your-django-sites/
django:通过 nginx 提供静态文件
https://serverfault. com/questions/122809/django-serving-static-files-through-nginx
https ://serverfault.com/questions/199038/serving-static-files-fails-nginx
Basically what it is saying is that you should use apache using mod_wsgi to serve your django application, and use a more lightweight web server like nginx to serve up your static content.
For example.
www.yourapp.com -> apache -> mod_wsgi -> your django app
static.yourapp.com -> nginx
By separating your concerns you can configure your apache instance to be your dump truck handing the heavy processing, and your nginx server to be light and fast like a racecar serving lots of little static files.
If you configure nginx so that it handles all web traffic, you can reverse proxy all django requests to apache behind it, and intercept all of the static files and serve those strait from nginx.
see these links for more information.
http://codespatter.com/2009/04/23/how-to-speed-up-your-django-sites/
django : Serving static files through nginx
https://serverfault.com/questions/122809/django-serving-static-files-through-nginx
https://serverfault.com/questions/199038/serving-static-files-fails-nginx
Ken 的评估和建议在 NGINX 代理后面提供所有服务是正确的。这就是要走的路。
您可以将应用程序和媒体服务器放在同一服务器或不同服务器上。对于大多数应用程序来说,这并不重要,并且可以从同一台计算机同时提供媒体和应用程序服务。
如果您正在考虑大量用户和大量流量,将媒体服务器分解到它自己的机器中将防止两者相互崩溃,并为您提供更多的灵活性。
如果您还没有使用过 Gunicorn,请查看它,因为它是一个快如闪电、易于部署的应用程序服务器,并且是新热门。
Ken is right in his assessment and in recommending serving everything behind a NGINX proxy. That is the way to go.
You can have your application and media servers on the same server or different ones. For most applications, it won't matter and it is fine to serve both media and apps from the same machine.
If you are looking at lots of users and heavy traffic, breaking the media server out into it's own machine will prevent the two from crashing each other and allow you a bit more flexibility.
Check out Gunicorn if you haven't already as it is a lightning fast, easy to deploy application server and is the new hotness.