Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
568 views
in Technique[技术] by (71.8m points)

deployment - Is it possible to host multiple django projects under the same domain?

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

  • example.com/2012/
  • example.com/2014/

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Yes.

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

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

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...