经过几个小时的努力,我已经决定放弃了,请求帮助:)
我在Debian 7的Apache2上运行了两个Django 1.6站点。我有一个虚拟主机。
我想让虚拟主机的根域去一个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/
但是,如果我想使用根(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去另一个….
我原本是按照这个post来到我所在的地方,但是却找不到任何东西来帮助我绕开这个路障。
感谢支持,Mark
尝试在WSGIScriptAlias指令中添加选项“process-group”和“application-group”:
WSGIScriptAlias / /usr/local/projects/project_one/project_one/wsgi.py process-group = test1 application-group =%{GLOBAL}
…
WSGIScriptAlias / 2 /usr/local/projects/project_two/project_two/wsgi.py process-group = test2 application-group =%{GLOBAL}
也许有点晚,但你可以改变这些wsgi的顺序,它应该工作正常(为我的两个wsgi瓶应用程序工作)。 当你第一次使用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>
也许有人会觉得有帮助