WSGI中的两个单独的django站点(root和/ two)

时间:2014-04-30 17:44:10

标签: python django apache virtualhost

经过几个小时的尝试,我决定放弃并向SO寻求帮助:)

我在Debian 7上的Apache2上运行了两个Django 1.6站点。我有一个vhost。

我希望vhost的根域转到一个django站点(例如:mydomain.com),以及第二个站点的单独别名(例如:mydomain.com/two)。

我可以得到两个别名,如下所示:

    WSGIDaemonProcess test1 python-path=/usr/local/projects/project_one:/usr/local/virtualenvs/project/lib/python2.7/site-packages
    WSGIScriptAlias /one /usr/local/projects/project_one/project_one/wsgi.py
    <Location /one>
            WSGIProcessGroup test1
    </Location>

    WSGIDaemonProcess test2 python-path=/usr/local/projects/project_two:/usr/local/virtualenvs/project/lib/python2.7/site-packages
    WSGIScriptAlias /two /usr/local/projects/project_two/project_two/wsgi.py
    <Location /two>
            WSGIProcessGroup test2
    </Location>

如果我使用以下域名,这将有效:

http://mydomain.com/one/

http://mydomain.com/two/

但是如果我想使用root(mydomain.com)和另一个(mydomain.com/two),它将不起作用:

    WSGIDaemonProcess test1 python-path=/usr/local/projects/project_one:/usr/local/virtualenvs/project/lib/python2.7/site-packages
    WSGIScriptAlias / /usr/local/projects/project_one/project_one/wsgi.py
    <Location />
            WSGIProcessGroup test1
    </Location>

    WSGIDaemonProcess test2 python-path=/usr/local/projects/project_two:/usr/local/virtualenvs/project/lib/python2.7/site-packages
    WSGIScriptAlias /two /usr/local/projects/project_two/project_two/wsgi.py
    <Location /two>
            WSGIProcessGroup test2
    </Location>

我认为它不起作用,因为它试图使用站点二的WSGI文件运行站点一: WSGI脚本'/usr/local/projects/project_one/project/wsgi.py'。

我的问题是我怎样才能第二次尝试工作,所以mydomain.com转到一个项目,而mydomain.com/two转到另一个项目....

我最初关注this帖子来到达我所在的位置,但却无法找到任何可以帮助我绕过这个障碍的地方。

感谢支持, 标记

2 个答案:

答案 0 :(得分:4)

尝试在WSGIScriptAlias指令中添加“process-group”和“application-group”选项:

  

WSGIScriptAlias / /usr/local/projects/project_one/project_one/wsgi.py process-group = test1 application-group =%{GLOBAL}

...

  

WSGIScriptAlias / two /usr/local/projects/project_two/project_two/wsgi.py process-group = test2 application-group =%{GLOBAL}

答案 1 :(得分:0)

也许有点晚了,但你可以改变这些wsgi的顺序,它应该可以正常工作(为我的两个wsgi烧瓶应用程序工作)。当您第一次使用root时,它只会将所有地址识别为根子域,并忽略第二个别名。 只需要/两个你的第一个地址而不是root:

WSGIDaemonProcess test2 python-path=/usr/local/projects/project_two:/usr/local/virtualenvs/project/lib/python2.7/site-packages
WSGIScriptAlias /two /usr/local/projects/project_two/project_two/wsgi.py
<Location /two>
        WSGIProcessGroup test2
</Location>

WSGIDaemonProcess test1 python-path=/usr/local/projects/project_one:/usr/local/virtualenvs/project/lib/python2.    7/site-packages
WSGIScriptAlias / /usr/local/projects/project_one/project_one/wsgi.py
<Location />
        WSGIProcessGroup test1
</Location>

也许有人会觉得有用