gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 11:49:04 25 4
gpt4 key购买 nike

我正在尝试使用 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()

我的 Apache 的 httpd-app.conf:

<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 不支持这种上下文。

查看相关信息:

关于python - 2 个 Bitnami Django 项目同时运行 Apache WSGI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35096738/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com