我使用mod_wsgi在数字海洋上安装了Django,但它有500个内部服务器错误。当我查看apache错误日志时,这是我得到的:
[Mon Dec 16 20:45:53 2013] [error] [client 61.147.99.202] File does not exist: /var/www/web-console
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] mod_wsgi (pid=29891): Exception occurred processing WSGI script '/var/www/kaasib/kaasib/wsgi.py'.
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] Traceback (most recent call last):
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] self.load_middleware()
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 47, in load_middleware
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] mw_class = import_by_path(middleware_path)
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/utils/module_loading.py", line 21, in import_by_path
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] module = import_module(module_path)
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 40, in import_module
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] __import__(name)
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/middleware.py", line 3, in <module>
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] from django.contrib.auth.backends import RemoteUserBackend
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/backends.py", line 3, in <module>
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] from django.contrib.auth.models import Permission
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/models.py", line 48, in <module>
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] class Permission(models.Model):
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 96, in __new__
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] new_class.add_to_class('_meta', Options(meta, **kwargs))
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 264, in add_to_class
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] value.contribute_to_class(cls, name)
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 124, in contribute_to_class
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 34, in __getattr__
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] return getattr(connections[DEFAULT_DB_ALIAS], item)
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 198, in __getitem__
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] backend = load_backend(db['ENGINE'])
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 113, in load_backend
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] return import_module('%s.base' % backend_name)
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 40, in import_module
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] __import__(name)
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 17, in <module>
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
[Tue Dec 17 02:01:50 2013] [error] [client 175.110.123.23] ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] mod_wsgi (pid=29984): Exception occurred processing WSGI script '/var/www/kaasib/kaasib/wsgi.py'.
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] Traceback (most recent call last):
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] self.load_middleware()
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 47, in load_middleware
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] mw_class = import_by_path(middleware_path)
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/utils/module_loading.py", line 21, in import_by_path
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] module = import_module(module_path)
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 40, in import_module
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] __import__(name)
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/middleware.py", line 3, in <module>
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] from django.contrib.auth.backends import RemoteUserBackend
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/backends.py", line 3, in <module>
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] from django.contrib.auth.models import Permission
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/models.py", line 48, in <module>
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] class Permission(models.Model):
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 96, in __new__
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] new_class.add_to_class('_meta', Options(meta, **kwargs))
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 264, in add_to_class
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] value.contribute_to_class(cls, name)
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 124, in contribute_to_class
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 34, in __getattr__
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] return getattr(connections[DEFAULT_DB_ALIAS], item)
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 198, in __getitem__
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] backend = load_backend(db['ENGINE'])
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 113, in load_backend
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] return import_module('%s.base' % backend_name)
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 40, in import_module
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] __import__(name)
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 17, in <module>
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
[Tue Dec 17 02:07:26 2013] [error] [client 175.110.123.23] ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] mod_wsgi (pid=29959): Exception occurred processing WSGI script '/var/www/kaasib/kaasib/wsgi.py'.
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] Traceback (most recent call last):
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] self.load_middleware()
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 47, in load_middleware
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] mw_class = import_by_path(middleware_path)
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/utils/module_loading.py", line 21, in import_by_path
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] module = import_module(module_path)
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 40, in import_module
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] __import__(name)
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/middleware.py", line 3, in <module>
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] from django.contrib.auth.backends import RemoteUserBackend
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/backends.py", line 3, in <module>
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] from django.contrib.auth.models import Permission
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/models.py", line 48, in <module>
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] class Permission(models.Model):
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 96, in __new__
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] new_class.add_to_class('_meta', Options(meta, **kwargs))
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 264, in add_to_class
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] value.contribute_to_class(cls, name)
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 124, in contribute_to_class
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 34, in __getattr__
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] return getattr(connections[DEFAULT_DB_ALIAS], item)
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 198, in __getitem__
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] backend = load_backend(db['ENGINE'])
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 113, in load_backend
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] return import_module('%s.base' % backend_name)
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 40, in import_module
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] __import__(name)
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 17, in <module>
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
[Tue Dec 17 02:38:09 2013] [error] [client 175.110.123.23] ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
在最后一行,它说ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
。据我所知,需要安装python的MySQLdb模块。但我在本地机器上也有这样的问题,但那不是500内部服务器错误。现在也在服务器上,它是Debug true。因此,不要认为500内部服务器错误是由MySQL DB模块引起的。
所以任何想法导致500内部服务器错误的问题是什么?我认为mod_wsgi配置存在一些问题,但不确定。如果您有任何想法,请告诉我。
答案 0 :(得分:1)
需要一个系统包在linux上安装MySQLdb(使用aptitude),您可以使用以下命令安装它:
python-mysqldb - MySQL的Python接口
sudo apt-get install python-mysqldb
pip install MySQL-python