如何使用 mod_python 运行多个版本的 Django 应用程序?
我想在单独的 apache 名称虚拟主机上设置 Django 应用程序的测试版本和生产版本,并想知道执行此操作的最佳方法。
这是我所做的,似乎工作正常,但我想知道是否有更好的方法。
<VirtualHost *>
ServerName test.foo.bar
<Location "/app/">
SetHandler python-program
PythonPath "['/home/jdm/django-apps/xyz/test/'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE settings
PythonOption django.root /app
PythonDebug On
PythonInterpreter test
</Location>
</VirtualHost>
<VirtualHost *>
ServerName live.foo.bar
<Location "/app/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonPath "['/home/jdm/django-apps/xyz/live/'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE settings
PythonOption django.root /app
PythonDebug On
PythonInterpreter live
</Location>
</VirtualHost>
这些应用程序位于 /home/jdm/django-apps/xyz/live/ 和 /home/jdm/django-apps/xyz/test/ 中。这些应用程序位于 http://live.foo.bar/app/ 和 http://test.foo.bar/app/
I want to set up test and production versions of a Django app on separate apache name virtual hosts and wanted to know the best way to do this.
Here's what I've done, and it seems to work ok, but I'm wondering if there's a better way.
<VirtualHost *>
ServerName test.foo.bar
<Location "/app/">
SetHandler python-program
PythonPath "['/home/jdm/django-apps/xyz/test/'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE settings
PythonOption django.root /app
PythonDebug On
PythonInterpreter test
</Location>
</VirtualHost>
<VirtualHost *>
ServerName live.foo.bar
<Location "/app/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonPath "['/home/jdm/django-apps/xyz/live/'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE settings
PythonOption django.root /app
PythonDebug On
PythonInterpreter live
</Location>
</VirtualHost>
The apps live in /home/jdm/django-apps/xyz/live/ and /home/jdm/django-apps/xyz/test/. The apps are at http://live.foo.bar/app/ and http://test.foo.bar/app/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为 virtualenv 就是您所需要的。
I think virtualenv is what you need.