django 和 mod_wsgi 配置错误
error in django & mod_wsgi config
我想在 ubuntu 服务器上配置我的 Django Web 应用程序但是有错误。
我在 Whosebug 中进行了搜索,但没有发现任何开发人员
这是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()
这是 /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>
最后在 ${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
看来您刚刚遇到了 http://bugs.python.org/issue21306 错误。您可以尝试将 python 升级到 2.7.7 或更高版本吗?
我想在 ubuntu 服务器上配置我的 Django Web 应用程序但是有错误。
我在 Whosebug 中进行了搜索,但没有发现任何开发人员
这是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()
这是 /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>
最后在 ${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
看来您刚刚遇到了 http://bugs.python.org/issue21306 错误。您可以尝试将 python 升级到 2.7.7 或更高版本吗?