简体   繁体   English

django和mod_wsgi配置错误

[英]error in django & mod_wsgi config

I want config My Django Web Application on ubuntu Server but has error. 我想在ubuntu服务器上配置我的Django Web应用程序,但是有错误。

I Searched in StackOverflow but not occurred for any developer 我在StackOverflow中进行搜索,但对于任何开发人员都没有发生

this is wsgi.py 这是wsgi.py

import os
import sys
sys.path.append('/var/www/Happ')
os.environ['DJANGO_SETTINGS_MODULE'] = 'Happ.settings'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

this is /etc/apache2/sites-available/000-default.conf 这是/etc/apache2/sites-available/000-default.conf

    <VirtualHost *:80>

        WSGIDaemonProcess Happ python-path=/var/www/Happ:/var/www/Happ/env/lib/python2.7/site-packages
        WSGIProcessGroup Happ
        WSGIScriptAlias / /var/www/Happ/Happ/wsgi.py process-group=Happ

        Alias /media/ /var/www/Happ/media/
        Alias /static/ /var/www/Happ/static/

        <Directory /var/www/Happ/static>
        Require all granted
        </Directory>

        <Directory /var/www/Happ/media>
        Require all granted
        </Directory>

        <Directory /var/www/Happ/Happ>
        <Files wsgi.py>
        Require all granted
        </Files>
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

and finally error in ${APACHE_LOG_DIR}/error.log 最后在$ {APACHE_LOG_DIR} /error.log中出错

[Tue Oct 13 12:19:34.614894 2015] [mpm_event:notice] [pid 27589:tid 140019869636480] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Tue Oct 13 12:19:34.615161 2015] [core:notice] [pid 27589:tid 140019869636480] AH00094: Command line: '/usr/sbin/apache2'
[Tue Oct 13 12:20:43.268750 2015] [mpm_event:notice] [pid 27589:tid 140019869636480] AH00491: caught SIGTERM, shutting down
[Tue Oct 13 12:20:44.387026 2015] [mpm_event:notice] [pid 27731:tid 139960612820864] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Tue Oct 13 12:20:44.387188 2015] [core:notice] [pid 27731:tid 139960612820864] AH00094: Command line: '/usr/sbin/apache2'
[Tue Oct 13 12:20:52.877249 2015] [:error] [pid 27734:tid 139960475911936] [remote 5.39.126.51:37150] mod_wsgi (pid=27734): Target WSGI script '/var/www/Happ/Happ/wsgi.py' cannot be loaded as Python module.
[Tue Oct 13 12:20:52.877311 2015] [:error] [pid 27734:tid 139960475911936] [remote 5.39.126.51:37150] mod_wsgi (pid=27734): Exception occurred processing WSGI script '/var/www/Happ/Happ/wsgi.py'.
[Tue Oct 13 12:20:52.877344 2015] [:error] [pid 27734:tid 139960475911936] [remote 5.39.126.51:37150] Traceback (most recent call last):
[Tue Oct 13 12:20:52.877373 2015] [:error] [pid 27734:tid 139960475911936] [remote 5.39.126.51:37150]   File "/var/www/Happ/Happ/wsgi.py", line 5, in <module>
[Tue Oct 13 12:20:52.877461 2015] [:error] [pid 27734:tid 139960475911936] [remote 5.39.126.51:37150]     from django.core.wsgi import get_wsgi_application
[Tue Oct 13 12:20:52.877482 2015] [:error] [pid 27734:tid 139960475911936] [remote 5.39.126.51:37150]   File "/var/www/Happ/env/lib/python2.7/site-packages/django/core/wsgi.py", line 2, in <module>
[Tue Oct 13 12:20:52.877548 2015] [:error] [pid 27734:tid 139960475911936] [remote 5.39.126.51:37150]     from django.core.handlers.wsgi import WSGIHandler
[Tue Oct 13 12:20:52.877567 2015] [:error] [pid 27734:tid 139960475911936] [remote 5.39.126.51:37150]   File "/var/www/Happ/env/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 11, in <module>
[Tue Oct 13 12:20:52.877699 2015] [:error] [pid 27734:tid 139960475911936] [remote 5.39.126.51:37150]     from django import http
[Tue Oct 13 12:20:52.877720 2015] [:error] [pid 27734:tid 139960475911936] [remote 5.39.126.51:37150]   File "/var/www/Happ/env/lib/python2.7/site-packages/django/http/__init__.py", line 2, in <module>
[Tue Oct 13 12:20:52.877789 2015] [:error] [pid 27734:tid 139960475911936] [remote 5.39.126.51:37150]     from django.http.request import (HttpRequest, QueryDict,
[Tue Oct 13 12:20:52.877809 2015] [:error] [pid 27734:tid 139960475911936] [remote 5.39.126.51:37150]   File "/var/www/Happ/env/lib/python2.7/site-packages/django/http/request.py", line 12, in <module>
[Tue Oct 13 12:20:52.878031 2015] [:error] [pid 27734:tid 139960475911936] [remote 5.39.126.51:37150]     from django.core import signing
[Tue Oct 13 12:20:52.878053 2015] [:error] [pid 27734:tid 139960475911936] [remote 5.39.126.51:37150]   File "/var/www/Happ/env/lib/python2.7/site-packages/django/core/signing.py", line 46, in <module>
[Tue Oct 13 12:20:52.878169 2015] [:error] [pid 27734:tid 139960475911936] [remote 5.39.126.51:37150]     from django.utils.crypto import constant_time_compare, salted_hmac
[Tue Oct 13 12:20:52.878191 2015] [:error] [pid 27734:tid 139960475911936] [remote 5.39.126.51:37150]   File "/var/www/Happ/env/lib/python2.7/site-packages/django/utils/crypto.py", line 8, in <module>
[Tue Oct 13 12:20:52.878305 2015] [:error] [pid 27734:tid 139960475911936] [remote 5.39.126.51:37150]     import hmac
[Tue Oct 13 12:20:52.878325 2015] [:error] [pid 27734:tid 139960475911936] [remote 5.39.126.51:37150]   File "/usr/local/lib/python2.7/hmac.py", line 8, in <module>
[Tue Oct 13 12:20:52.878462 2015] [:error] [pid 27734:tid 139960475911936] [remote 5.39.126.51:37150]     from operator import _compare_digest as compare_digest
[Tue Oct 13 12:20:52.878497 2015] [:error] [pid 27734:tid 139960475911936] [remote 5.39.126.51:37150] ImportError: cannot import name _compare_digest

It seems you've just hit the http://bugs.python.org/issue21306 bug. 看来您刚刚遇到了http://bugs.python.org/issue21306错误。 Can you try upgrading python to 2.7.7 or above? 您可以尝试将python升级到2.7.7或更高版本吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM