WSGI中的两个单独的django站点(根和/两个) [英] Two separate django sites in WSGI (root and /two)

查看:186
本文介绍了WSGI中的两个单独的django站点(根和/两个)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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



我希望vhost的根域可以转到一个django站点(例如:mydomain.com),另外还有一个别的别名:mydomain.com/two)



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



< blockquote>

  WSGIDaemonProcess test1 python-path = / usr / local / projects / project_one:/usr/local/virtualenvs/project/lib/python2.7/site-包
WSGIScriptAlias / one /usr/local/projects/project_one/project_one/wsgi.py
<位置/一个>
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
<位置/二>
WSGIProcessGroup test2
< / Location>


如果我使用以下域,这将工作:



http://mydomain.com/one/



http://mydomain.com/two/



但是,如果我想使用根(mydomain.com)和另一个(mydomain.com/two),它将无法正常工作:

  WSGIDaemonProcess test1 python-path = / usr / local / projects / project_one:/usr/local/virtualenvs/project/lib/python2.7/site-包
WSGIScriptAlias / /usr/local/projects/project_one/project_one/wsgi.py
<位置/>
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
<位置/二>
WSGIProcessGroup test2
< / Location>

我相信它不工作,因为它试图运行网站一的网站二的WSGI文件:
WSGI脚本'/usr/local/projects/project_one/project/wsgi.py'。



我的问题是如何获得第二次尝试工作,所以mydomain .com去一个项目,mydomain.com/two去另一个项目。



我最初跟着这个的帖子,以获得我所在的位置,但无法找到任何东西帮助我绕过这个路障。



欣赏支持,
Mark

解决方案

尝试在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}



After hours of trying I've decided to give in and ask SO for help :)

I have two Django 1.6 sites running on Apache2 on Debian 7. I have one vhost.

I want the root domain for the vhost to go to one django site (example: mydomain.com), and a separate alias for the second site (example: mydomain.com/two).

I can get two alias to work like below:

    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>

This will work if I use the following domains:

http://mydomain.com/one/

http://mydomain.com/two/

But if I want to use the root (mydomain.com) and another (mydomain.com/two), it will not work:

    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>

I believe it is not working because it's trying to run site one with site two's WSGI file: WSGI script '/usr/local/projects/project_one/project/wsgi.py'.

My question is how can I get the second attempt to work so mydomain.com goes to one project, and mydomain.com/two goes to another....

I originally followed this post to get to where I am, but not been able to find anything to help me get round this roadblock.

Appreciate the support, Mark

解决方案

Try add the options "process-group" and "application-group" in the WSGIScriptAlias directive:

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}

这篇关于WSGI中的两个单独的django站点(根和/两个)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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