我正在尝试使用Apache和WSGI在服务器的不同端口上运行两个django应用程序。这是我的VehicleDataEntry.conf(监听端口80)文件:
<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName 104.218.50.242
DocumentRoot /website_data/sites/VehicleDataEntry/static/
WSGIScriptAlias / /website_data/django/VehicleDataEntry/VehicleDataEntry/wsgi.py
Alias /static/ /website_data/sites/VehicleDataEntry/static/
</VirtualHost>
WSGIPythonPath /website_data/django/VehicleDataEntry/
<Directory "/website_data/sites/VehicleDataEntry/static">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory "/website_data/django/VehicleDataEntry/VehicleDataEntry">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
QuotationMaker.conf(侦听端口8080):
<VirtualHost *:8080>
ServerAdmin webmaster@example.com
ServerName 104.218.50.242
DocumentRoot /website_data/sites/QuotationMaker/static/
WSGIScriptAlias / /website_data/django/QuotationMaker/QuotationMaker/wsgi.py
Alias /static/ /website_data/sites/QuotationMaker/static/
</VirtualHost>
WSGIPythonPath /website_data/django/QuotationMaker/
<Directory "/website_data/sites/QuotationMaker/static">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory "/website_data/django/QuotationMaker/QuotationMaker">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
现在是VehicleDataEntry的wsgi.py文件:
import os
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
os.environ["DJANGO_SETTINGS_MODULE"] = "VehicleDataEntry.settings"
application = get_wsgi_application()
application = DjangoWhiteNoise(application)
QuotationMaker的wsgi.py文件: VehicleDataEntry的wsgi.py文件:
import os
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
os.environ["DJANGO_SETTINGS_MODULE"] = "QuotationMaker.settings"
application = get_wsgi_application()
application = DjangoWhiteNoise(application)
问题:VehicleDataEntry应用程序正在运行,没有任何问题,但是,当我尝试在端口8080上访问QuotationMaker时,它返回500内部服务器错误。当我检查httpd / logs / error_log时,出现以下错误:
ImportError:没有名为QuotationMaker.settings
的模块我知道DJANGO_SETTINGS_MODULE路径有问题,也在线查找,但无法找到解决方案。请帮忙。
答案 0 :(得分:0)
你不能在全局范围内设置WSGIPythonPath
两次,第二次会覆盖第一次。
读:
与运行多个Django站点相关的其他问题。
您应该使用mod_wsgi守护程序模式并将每个Django站点放在自己的进程中。
同时阅读:
解释了如何使用Python虚拟环境,以及有关设置Python模块搜索路径的正确方法的更多详细信息。