服务与同code 2 Django的网站 [英] Serving 2 django sites with the same code
问题描述
我使用的是Apache的配置如下供应Django的网站与Apache和WSGI:
I'm serving a django site with apache and wsgi using an apache config as follow:
Alias /media/ /var/www/media/
Alias /files/ /var/www/files/
WSGIDaemonProcess fc processes=5 threads=5 display-name=%{GLOBAL}
WSGIProcessGroup fc
WSGIScriptAlias / /home/path/to/django.wsgi
该应用程序供应主机的根目录。现在我想改变这个,所以我可以在 HTTP服务它://主机/ APP1 以及一个又一个,用不同的Django的设置,请在的http://主机/ APP2
The app is served in the root directory of the host. I'd like now to change this so I can serve it at http://host/app1 and another one, with a different django setting, at http://host/app2
我怎样才能更改配置做到这一点?
How can I change the config to do this?
感谢
推荐答案
您需要一套 WSGI *
指令对每一个项目的。这第二个参数 WSGIScriptAlias
告诉Apache在项目住在树上;该URL传递给Django的URL解析之前WSGI删除此preFIX。
You'll need a set of WSGI*
directives for each project. That second parameter to WSGIScriptAlias
tells Apache where the project lives in the tree; WSGI removes this prefix before the URL is passed to Django's URL resolver.
例如:
WSGIDaemonProcess app1 threads=15
WSGIScriptAlias /app1 /var/www/django_project1/django.wsgi
<Location /app1>
WSGIProcessGroup app1
</Location>
WSGIDaemonProcess app2 threads=15
WSGIScriptAlias /app2 /var/www/django_project2/django.wsgi
<Location /app2>
WSGIProcessGroup app2
</Location>
我没有试过优化这一点;有可能是一个更好的办法。但是,这应该让你在运行。
I haven't tried to optimize this; there may be a better way. But this should get you running.
这篇关于服务与同code 2 Django的网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!