使用两个不同的python版本的apache2中的WSGI错误(Django App)

时间:2018-08-07 11:36:03

标签: python django apache mod-wsgi

我正在尝试使用不同的python版本(2.7和3.5)在ubuntu的Apache2服务器上设置两个Django应用。

apache conf:

WSGIDaemonProcess site1  display-name=%{GROUP} 
WSGIScriptAlias /site1 /var/www/bigb/site1/site1/wsgi.py
    <Location /site1>
        WSGIProcessGroup site1
        WSGIApplicationGroup %{GLOBAL}
    </Location>
WSGIDaemonProcess vdms display-name=%{GROUP}
WSGIScriptAlias /vdms /var/www/bigb/vdms/vdms/wsgi.py 
    <Location /vdms>
        WSGIProcessGroup vdms
        WSGIApplicationGroup %{GLOBAL}
    </Location>
    <Location /site1>
        WSGIProcessGroup site1
        WSGIApplicationGroup %{GLOBAL}
    </Location>
   <Directory /var/www/bigb/vdms/vdms>
    <Files wsgi.py>
        Require all granted
    </Files>
  </Directory>
  <Directory /var/www/bigb/site1/site1>
    <Files wsgi.py>
        Require all granted
    </Files>
  </Directory>

site1的Wsgi.py文件:

from django.core.wsgi import get_wsgi_application
sys.path.append('/var/www/bigb/site1')
sys.path.append('/var/www/bigb/site1/venv/lib/python3.5/site-packages')
os.environ["DJANGO_SETTINGS_MODULE"]= "site1.settings"
application = get_wsgi_application()

vdms的Wsgi.py文件:

from django.core.wsgi import get_wsgi_application
sys.path.append('/var/www/bigb/vdms')
sys.path.append('/var/www/bigb/vdms/venv/lib/python2.7/site-packages')
os.environ["DJANGO_SETTINGS_MODULE"]= "vdms.settings"
application = get_wsgi_application()

当我尝试运行apache服务器时,我可以访问site1,但是当我尝试加载vdms时,出现内部服务器错误

 raise RuntimeError("populate() isn't reentrant")
[Tue Aug 07 11:25:03.426115 2018] [wsgi:error] [pid 12920] [remote 192.168.1.14:57874] RuntimeError: populate() isn't reentrant
[Tue Aug 07 11:25:03.426095 2018] [wsgi:error] [pid 12920] [remote 192.168.1.14:57874]     apps.populate(settings.INSTALLED_APPS)
[Tue Aug 07 11:25:03.426100 2018] [wsgi:error] [pid 12920] [remote 192.168.1.14:57874]   File "/usr/local/lib/python3.5/dist-packages/django/apps/registry.py", line 81, in populate

我已经在系统上安装了libapache2-mod-wsgi-py3和libapache2-mod-wsgi,并且还在venv中安装了mod_wsgi。我可以在配置中添加两个LoadModule还是有配置错误?请教育我解决这个问题

0 个答案:

没有答案