我正在尝试使用wsgi在Apache中设置2个Django项目,我似乎遇到了apache的conf文件的问题(我对此知之甚少)
我有2个项目(“MyTestProjOne”和“Project” - 命名我知道: - /)
如果我重新启动Apache服务器并首先转到[servername]/Project
,它将启动。但是,一旦我转到[servername]/MyTestProjOne
,就说can not match url to Project.urls
它会逆转。
所有这些症状都是由于wsgi没有以守护进程模式运行,而是我通过谷歌学到的,但是我不知道如何修复它。
这是类似的问题,但是没有一个解决方案解决了这个问题,因为我无法在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(“项目”)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>
答案 0 :(得分:2)
不要设置:
WSGIApplicationGroup %{GLOBAL}
您正在强制两个应用程序在相同的解释器上下文中运行,Django因使用环境变量而不支持。
请参阅以下相关信息: