Django - 具有Apache虚拟主机的中间件或子域的子域? [英] Django - Subdomains with Middleware or Subdomains with Apache Virtual Hosts?

查看:126
本文介绍了Django - 具有Apache虚拟主机的中间件或子域的子域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚到Django ...

I'm new to Django...

我需要启动一个有子域名的项目,但我对这个主题感到困惑...

I need to start a project that will have subdomains, but I'm little confused about this subject...

我将有一个网站服务西班牙,其他服务英国和其他服务美国,我将只使用一个域和3个子域,就像这样:

I will have a website serving Spain, other serving United Kingdom and other serving United States and I will use only one domain and 3 subdomains, just like this:

主域名:

mysite.com

子域:

es.mysite.com
uk.mysite.com
us.mysite.com

这些3个不同的站点在将来可能不得不扩展,每一个在一个专用服务器,但现在这3个网站将使用相同的服务器。

These 3 different site in future could have to scale, each one in one dedicated server, but for now these 3 websites will use the same server.

在上一个问题,我是被告知要使用中间件解决方案(http://thingsilearned.com/2009/01/05/using-subdomains-in-django/),但是我不知道这是否需要我。有了这个解决方案,如果我需要扩展专用服务器的网站,我认为不会工作...

In a previous question I was told to use a middleware solution(http://thingsilearned.com/2009/01/05/using-subdomains-in-django/) but I don't konw if it this that I need. With this solution if I need to scale the websites for dedicated servers each one I think will not work...

可以在Apache虚拟主机中定义子域?您认为使用3个不同的Django项目与Apache虚拟主机会做什么?这是一个更好的解决方案,或者我应该用中间件?

It is possible to define instead the subdomains in Apache Virtual Hosts? What do you think of using 3 different Django projects with Apache Virtual Hosts will doing the job? This is a better solution or I should go with middleware?

最好的问候,

推荐答案

如果您希望将子域扩展到不同的服务器,最简单的解决方案可能是在您的Web服务器上使用虚拟主机。

If you're looking to expand the subdomains to different servers eventually, the easier solution will probably be using virtual hosts on your web server.

每个主机可以使用单独的设置模块(它们都可以从通用设置模块导入*,更改特定于该域的任何数据库/语言设置)。

Each host can just use a separate settings module (they can all import * from a common settings module, changing any database / language settings which are specific to that domain).

部署此方式意味着你拥有更高的内存使用率,因为您将处理每个域的单独实例,但这听起来不像是您和您的长期方向的问题。它也使事情更简单,使用中间件可能会变得凌乱(特别是与测试等)。

Deploying this way means you have a higher memory usage, since you will be dealing with separate instances for each domain, but that doesn't sound like it will be a problem for you and your long term direction. It also makes things simpler, using middleware can get messy (especially with tests and the like).

这篇关于Django - 具有Apache虚拟主机的中间件或子域的子域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆