2 个 Bitnami Django 项目 运行 同时 Apache WSGI

2 Bitnami Django Projects Running at same time Apache WSGI

我正在尝试使用 wsgi 在 Apache 中设置 2 个 Django 项目,我似乎在使用 apache 的 conf 文件时遇到了问题(我对此知之甚少)

我有 2 个项目("MyTestProjOne" 和 "Project" - 我知道命名 :-/ )

如果我重新启动 Apache 服务器并首先转到 [servername]/Project,它将启动。但是一旦我去 [servername]/MyTestProjOne 它说 can not match url to Project.urls 然后它反转了。

所有这些症状都是由于 wsgi 未 运行 根据我通过 google 了解到的守护进程模式,但我不知道如何修复它。

这是与此类似的问题,但是 none 的解决方案解决了这个问题,因为我无法在 windows 机器上 运行 守护进程模式(根据我的被告知)。 Deploying multiple django apps on Apache with mod_wsgi

我的 wsgi 文件用于项目一 ("MyTestProjOne") wsgi.py:

import os, sys
sys.path.append('C:/Users/user/Bitnami Django Stack projects/MyTestProjOne')
os.environ.setdefault("PYTHON_EGG_CACHE", "C:/Users/user/Bitnami Django Stack projects/MyTestProjOne/egg_cache")


from django.core.wsgi import get_wsgi_application

os.environ["DJANGO_SETTINGS_MODULE"] = "MyTestProjOne.settings"

application = get_wsgi_application()

对于项目 2 ("Project") wsgi.py:

from django.core.wsgi import get_wsgi_application

os.environ['DJANGO_SETTINGS_MODULE'] = "Project.settings"

application = get_wsgi_application()

我的 httpd-app.conf 用于 Apache:

<VirtualHost _default_:8007>
    DocumentRoot "C:/Bitnami/djangostack-1.8/apache2/htdocs"
      <Directory "C:/Bitnami/djangostack-1.8/apache2/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride All
      <IfVersion < 2.3 >
    Order allow,deny                          
    Allow from all
</IfVersion>
<IfVersion >= 2.3 >
  Require all granted
</IfVersion>
</Directory>

# Error Documents
ErrorDocument 503 /503.html

# Bitnami applications installed with a prefix URL (default)
Include "C:/Users/user/Bitnami Django Stack projects/Project/conf/httpd-app.conf"
Include "C:/Users/user/Bitnami Django Stack projects/MyTestProjOne/conf/httpd-app.conf""
</VirtualHost>

MyTestProjOne httpd-app.conf:

WSGIScriptAlias /MyTestProjOne 'C:/Users/user/Bitnami Django Stack projects/MyTestProjOne/MyTestProjOne/wsgi.py'
<Directory "C:/Users/user/Bitnami Django Stack projects/MyTestProjOne/MyTestProjOne">
Options +MultiViews
AllowOverride All
<IfVersion < 2.3 >
    Order allow,deny
    Allow from all
</IfVersion>
<IfVersion >= 2.3>
    Require all granted
</IfVersion>
WSGIApplicationGroup %{GLOBAL}
<IfVersion < 2.3 >
    Order allow,deny
    Allow from all
</IfVersion>
<IfVersion >= 2.3>
    Require all granted
</IfVersion>  
</Directory>

<Directory "C:/Users/user/Bitnami Django Stack projects/MyTestProjOne">
Options +MultiViews
AllowOverride All
<IfVersion < 2.3 >
    Order allow,deny
    Allow from all
</IfVersion>
<IfVersion >= 2.3>
    Require all granted
</IfVersion>
</Directory>

Alias /staticMyTestProjOne "C:/Users/user/Bitnami Django Stack Projects/MyTestProjOne/static"

项目 httpd-app.conf:

Alias /static "C:/Users/user/Bitnami Django Stack Projects/Project/static"
WSGIScriptAlias /Project 'C:/Users/user/Bitnami Django Stack projects/Project/Project/wsgi.py'

<Directory "C:/Users/user/Bitnami Django Stack projects/Project/Project">
Options +MultiViews
AllowOverride All
<IfVersion < 2.3 >
    Order allow,deny
    Allow from all
</IfVersion>
<IfVersion >= 2.3>
    Require all granted
</IfVersion>


<IfVersion < 2.3 >
    Order allow,deny
    Allow from all
</IfVersion>
<IfVersion >= 2.3>
    Require all granted
</IfVersion>

</Directory>

<Directory "C:/Users/user/Bitnami Django Stack projects/Project">

WSGIApplicationGroup %{GLOBAL}
Options +MultiViews
AllowOverride All
<IfVersion < 2.3 >
    Order allow,deny
    Allow from all
</IfVersion>
<IfVersion >= 2.3>
    Require all granted
</IfVersion>
</Directory>

不设置:

WSGIApplicationGroup %{GLOBAL}

您强制两个应用程序 运行 在同一个解释器上下文中,由于使用了环境变量,Django 不支持。

查看相关信息: