如何为多个单独的 Django 实例配置 Apache WSGI? [英] Howto configure Apache WSGI for multiple separate Django instances?

查看:21
本文介绍了如何为多个单独的 Django 实例配置 Apache WSGI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 apache 实例,其中包含以下内容

I have an apache instance where I have the following

WSGIPythonPath /production/somelocation/django12/lib/python2.4/site-packages/
<VirtualHost 192.168.1.1:443>
        WSGIScriptAlias / /opt/project.wsgi
        .....

我的 Django 1.5 应用程序 apache 配置看起来像,

My Django 1.5 app apache config looks like,

WSGIPythonPath /production/somelocation/django15/lib/python2.7/site-packages/
<VirtualHost 192.168.1.2:443>
        ....
        WSGIScriptAlias / /opt/project2.wsgi

我的/opt/project.wsgi 看起来像

My /opt/project.wsgi looks like

import os
import sys

# django1.2 virtualenv
import site
site.addsitedir("/production/somelocation/django12/lib/python2.4/site-packages")
.....

然而,当我访问该站点时,我仍然得到默认的 django (1.5) 实例.我错过了什么?

However when I go to the site I still get my default django (1.5) instance. What am I missing ?

推荐答案

其他答案提到设置 python 路径,但是使用 WSGIPythonPath 或 WSGIPythonHome 是不正确的.WSGIPythonPath/WSGIPythonHome 只能设置服务器范围,因此每个虚拟主机没有不同的路径.

The other answers mention setting the python path, however using WSGIPythonPath or WSGIPythonHome are not correct. The WSGIPythonPath / WSGIPythonHome can only be set server-wide, so no different paths per virtualhost.

您可能想要使用 WSGIDaemonProcess python-pathhome 参数,用于设置每个虚拟主机的 python 路径和应用程序主目录.

You would want to use the WSGIDaemonProcess python-path and home arguments to set the python path and your apps home directory per virtualhost.

此外,在您的代码中,无需调整 python 路径;只需确保您的虚拟主机配置正确即可.

Also, within your code there is no need to adjust python paths; just make sure your virtualhost config is correct.

这篇关于如何为多个单独的 Django 实例配置 Apache WSGI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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