I installed Django on digital ocean using mod_wsgi, but it is having 500 Internal Server Error. When I look in apache error log, here is what I got:
[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
On last line, it says, ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
. By that I guess there, python's MySQLdb module need to be installed. But I had such problem on local machine too, but that wasn't 500 Internal server error. Also right now on server, it is Debug true. So don't think that 500 Internal Server error was due to MySQL DB module.
So any idea what is the problem that is causing 500 Internal Server error? I think there is some problem in mod_wsgi configuration but not sure. Please let me know if you have any idea.
a system package is required to install MySQLdb on linux (with aptitude) you can install it using:
python-mysqldb - Python interface to MySQL
sudo apt-get install python-mysqldb
pip install MySQL-python