Apache 如何访问服务器上wsgi站点的多个副本

Apache 如何访问服务器上wsgi站点的多个副本,apache,flask,wsgi,Apache,Flask,Wsgi,我有一个Flask网站在apache服务器上提供服务,现在我想在同一台服务器上运行另一个代码库副本,以便在不同的svn分支上进行测试。因此,我已将代码库安装在服务器上的其他位置,并向apache conf文件添加了另一个引用测试代码库的WSGIScriptAlias条目: # Entry point for the user web interface: WSGIScriptAlias /mysite /blah/blah/wsgi_entry.py # Entry point for the

我有一个Flask网站在apache服务器上提供服务,现在我想在同一台服务器上运行另一个代码库副本,以便在不同的svn分支上进行测试。因此,我已将代码库安装在服务器上的其他位置,并向apache conf文件添加了另一个引用测试代码库的WSGIScriptAlias条目:

# Entry point for the user web interface:
WSGIScriptAlias /mysite /blah/blah/wsgi_entry.py

# Entry point for the test branch of the user web interface:
WSGIScriptAlias /mysiteTEST /blah/blah/testBranch/wsgi_entry.py
我希望将浏览器发送到mysiteTEST而不是通常的mysite会让我在测试分支中运行代码。但是,它运行的是原始代码,可能是因为wsgi_entry.py只执行以下操作:

from my_main_module import app as application
它寻找我的主模块的地方大概是apache配置中设置的python路径,如下所示:

WSGIPythonPath /blah/blah/main_code_place

这对于主站点来说是正确的,但是我想让mysiteTEST在测试分支位置运行模块。因此,也许我可以在testBranch/wsgi_entry.py中重写python路径,也许不可以,但是有没有一种更简单的方法可以在apache配置中管理它呢?例如,我可以为/mysite指定一个WSGIPythonPath,为/mysiteTEST指定另一个WSGIPythonPath吗?

设置多个虚拟主机:

<VirtualHost your.ip:80>
ServerName blahblah
ServerAdmin blahblah@blah.com
WSGIDaemonProcess blahblah user=b group=lah threads=5
WSGIScriptAlias /mysite /blah/blah/wsgi_entry.py

<Directory /blah/blah>
    Options Indexes FollowSymLinks Includes ExecCGI
    WSGIScriptReloading On
    WSGIProcessGroup blahblah
    WSGIApplicationGroup %{GLOBAL}
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>

<VirtualHost your.ip:80>
ServerName blahblahTEST
ServerAdmin blahblah@blah.com
WSGIDaemonProcess blahblahtest user=b group=lah threads=5
WSGIScriptAlias /mysiteTEST /blah/blah/testBranch/wsgi_entry.py

<Directory /blah/blah/testBranch>
    Options Indexes FollowSymLinks Includes ExecCGI
    WSGIScriptReloading On
    WSGIProcessGroup blahblah
    WSGIApplicationGroup %{GLOBAL}
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>

最后,我添加了一行代码来修改替代代码版本的wsgi入口点中的路径,即我的示例中apache配置行WSGIScriptAlias/mysiteTEST/blah/blah/testBranch/wsgi_entry.py中引用的文件。该行覆盖wsgi配置的python搜索路径。这不是我想要的apache config唯一解决方案,但它只是一个单行添加,可以完成以下任务:

import sys
sys.path.insert(0, '<path for alternate code modules>')    
from my_main_module import app as application

不确定所有其他设置是否适用于您,但总的来说,这应该可以让您继续。谢谢,但这似乎不起作用。我开始设置单独的虚拟主机,但看起来无法在虚拟主机上下文中指定WSGIPythonPath指令:WSGIPythonPath不能出现在节中将WSGIPythonPath行移到VirtualHost节之外问题的原因是WSGIPythonPath对于两个代码基是公共的,这两个代码基在模块名称上是相同的。因此,将WSGIPythonPath移动到全局范围不会提供解决方案。