处理wsgi脚本时发生异常

时间:2019-07-11 12:40:10

标签: django apache centos7 mod-wsgi

我有一个Django 2.0.5应用程序和一个带有httpd的Centos7服务器。我想使用httpd部署应用程序,但是当apache处理wsgi脚本时收到错误消息

mod_wsgi (pid=17647): Exception occurred processing WSGI script '/var/www/html/quiq/apache.conf/web.wsgi'.
TypeError: 'NoneType' object is not iterable
mod_wsgi (pid=17648): Exception occurred processing WSGI script '/var/www/html/quiq/apache.conf/web.wsgi'.
TypeError: 'NoneType' object is not iterable

WSGI脚本

import os, sys
#import django.core.handlers.wsgi

sys.path.append('/var/www/html/quiq/')

os.environ['DJANGO_SETTINGS_MODULE'] = 'Rest_SL_Algorithm.settings'

# avoid UnicodeEncodeError
os.environ.setdefault("LANG", "en_US.UTF-8")
os.environ.setdefault("LC_ALL", "en_US.UTF-8")
from django.core.wsgi import get_wsgi_application

##activamos nuestro virtualenv
activate_this = '/var/www/html/quiq/quiqenv/bin/activate_this.py'
#execfile(activate_this, dict(__file__=activate_this))
#exec(open('/var/www/html/quiq/quiqenv/bin/activate_this.py').read())
exec(compile(open(activate_this, "rb").read(), activate_this, 'exec'), dict(__file__=activate_this))
#_application = django.core.handlers.wsgi.WSGIHandler()
_application = get_wsgi_application()


def application(environ, start_response):
    environ['PATH_INFO'] = environ['SCRIPT_NAME'] + environ['PATH_INFO']
    if environ['wsgi.url_scheme'] == 'https':
        environ['HTTPS'] = 'on'
        return _application(environ, start_response)

和该项目的httpd conf

<virtualhost *:80>

    ServerName algorithm

    DocumentRoot /var/www/html/quiq

    <Directory /var/www/html/quiq>
        Order allow,deny
        Allow from all
    </Directory>

    WSGIDaemonProcess dev.algorithm.com processes=2 threads=15 display-name=%{GROUP}

    WSGIProcessGroup dev.algorithm.com

    WSGIScriptAlias / /var/www/html/quiq/apache.conf/web.wsgi

    Alias /media /var/www/html/quiq/media/
    <Directory /var/www/html/quiq/media>
        Require all granted
    </Directory>

    Alias /static/ /var/www/html/quiq/staticfiles/
    <Directory /var/www/html/quiq/staticfiles>
        Require all granted
    </Directory>

    ErrorLog /etc/httpd/logs/pyerror.log
    CustomLog /etc/httpd/logs/pyaccess.log combined

</virtualhost>

在centos上安装时,如安装centos-release-sclrh-python

,我必须做一些变通的工作。

最奇怪的是,当我在python控制台上执行相同的命令时,它告诉我找不到django模块。

我该怎么办? 预先感谢!

0 个答案:

没有答案