如何使用 mod_python 运行多个版本的 Django 应用程序?

发布于 2024-08-23 23:45:40 字数 1243 浏览 2 评论 0原文

我想在单独的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

且行且努力 2024-08-30 23:45:40

我认为 virtualenv 就是您所需要的。

I think virtualenv is what you need.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文