是否可以在同一个域下托管多个Django项目? [英] Is it possible to host multiple django projects under the same domain?

查看:63
本文介绍了是否可以在同一个域下托管多个Django项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将具有Django CMS的不同Django项目放在同一域下,例如:

I need to put different Django projects with Django CMS under the same domain, for example:


  • example.com/2012/

  • example.com/2014 /

通常我为每个域/使用virtualenv和mod_wsgi项目。我将需要不同的数据库,媒体文件和Django版本。

Normally I am using virtualenv and mod_wsgi for each domain/project. I will need different databases, media files, and Django versions.

在这里不能将项目放置在不同的子域下。

Putting projects under different subdomains is not an option here.

有可能吗?我应该如何设置服务器?有什么警告我应该知道吗?

Is it possible to do? How should I setup the server? Are there any caveats I should know?

推荐答案

是。

您可以配置Apache / mod_wsgi重写URL并将其定向到不同的WSGI文件。这使您可以为每个站点设置完全不同的virtualenvs,数据库和Django版本。例如:

You can configure Apache / mod_wsgi to rewrite URLs and to direct them to different WSGI files. This allows you to setup entirely different virtualenvs, databases and Django versions for each site. For example:

WSGIScriptAlias /2012/ /location/to/my/files/website1.wsgi
WSGIScriptAlias /2014/ /location/to/my/files/website2.wsgi

然后每个这些WSGI文件都可以直接

Each of these WSGI files can then direct execution to files in a particular virtualenv with their own Django version and settings.

如果可以放宽需要不同Django版本的约束,则可以使用 django.contrib.sites 框架。这样,您就可以为每个网站定义多个 Site 对象。然后,您可以在运行Django安装时将内容与每个站点相关联。

If you can loosen the constraint that you need different Django version then you can use the django.contrib.sites framework. This allows you to define multiple Site objects, once for each "website". You can then associate content with each of the sites while running one installation of Django.

这篇关于是否可以在同一个域下托管多个Django项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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