我正在尝试设置apache,mod_wsgi和django。我的apache错误日志中出现了内部服务器错误:
[Wed Jun 22 21:31:55 2011] [error] [client ::1] mod_wsgi (pid=2893): Target WSGI script '/django/internal/django-development.wsgi' cannot be loaded as Python module.
[Wed Jun 22 21:31:55 2011] [error] [client ::1] mod_wsgi (pid=2893): Exception occurred processing WSGI script '/django/internal/django-development.wsgi'.
[Wed Jun 22 21:31:55 2011] [error] Traceback (most recent call last):
[Wed Jun 22 21:31:55 2011] [error] File "/django/internal/django-development.wsgi", line 3, in <module>
[Wed Jun 22 21:31:55 2011] [error] import sys, os
[Wed Jun 22 21:31:55 2011] [error] ImportError: No module named os
[Wed Jun 22 21:31:55 2011] [error] [client ::1] mod_wsgi (pid=2893): Target WSGI script '/django/internal/django-development.wsgi' cannot be loaded as Python module.
[Wed Jun 22 21:31:55 2011] [error] [client ::1] mod_wsgi (pid=2893): Exception occurred processing WSGI script '/django/internal/django-development.wsgi'.
[Wed Jun 22 21:31:55 2011] [error] Traceback (most recent call last):
[Wed Jun 22 21:31:55 2011] [error] File "/django/internal/django-development.wsgi", line 3, in <module>
[Wed Jun 22 21:31:55 2011] [error] import sys, os
[Wed Jun 22 21:31:55 2011] [error] ImportError: No module named os
的django-development.wsgi
#! /usr/bin/env python
import sys, os
path = '/django/internal'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'internal.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
请告诉我是否有任何内容(例如配置文件)我可以发帖以帮助您诊断此问题。
编辑:
这很奇怪,考虑到我认为我将默认的python版本设置为2.5 ..,并使用python2.5作为参数运行./configure
$otool -L mod_wsgi.somod_wsgi.so:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.10)
/System/Library/Frameworks/Python.framework/Versions/2.6/Python (compatibility version 2.6.0, current version 2.6.1)
和
LoadModule wsgi_module libexec/apache2/mod_wsgi.so
WSGIScriptAlias / /django/internal/django-development.wsgi
编辑:
啊,看起来导入的配置文件很糟糕。我已经把它给了我以下输出。进展:
[Wed Jun 22 23:04:28 2011] [error] Exception ImportError: 'No module named atexit' in 'garbage collection' ignored
Fatal Python error: unexpected exception during garbage collection
[Wed Jun 22 23:04:28 2011] [error] Exception ImportError: 'No module named atexit' in 'garbage collection' ignored
Fatal Python error: unexpected exception during garbage collection
[Wed Jun 22 23:04:29 2011] [notice] caught SIGTERM, shutting down
[Wed Jun 22 23:04:29 2011] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Wed Jun 22 23:04:29 2011] [warn] mod_wsgi: Compiled for Python/2.5.4.
[Wed Jun 22 23:04:29 2011] [warn] mod_wsgi: Runtime using Python/2.6.1.
[Wed Jun 22 23:04:29 2011] [notice] Digest: generating secret for digest authentication ...
[Wed Jun 22 23:04:29 2011] [notice] Digest: done
[Wed Jun 22 23:04:29 2011] [notice] Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8l DAV/2 mod_wsgi/3.3 Python/2.6.1 configured -- resuming normal operations
[Wed Jun 22 23:06:04 2011] [error] [client ::1] client denied by server configuration: /django/internal/django-development.wsgi
修改的
所以,我还是想弄清楚如何让mod_wsgi运行python 2.5而不是2.6 - 这就是我现在面临的重大问题。除此之外,它应该只是调整apache配置。