【发布时间】:2016-05-07 21:49:32
【问题描述】:
我正在尝试使用 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>
【问题讨论】:
标签: python django windows apache wsgi