I am trying to set up Apache and Django. I have the file django.wsgi at project root with the following content
import os
import sys
# activate virtualenv
activate_this = os.path.expanduser(
"/var/www/continue/env-continue/bin/activate_this.py"
)
execfile(activate_this, dict(__file__=activate_this))
PROJECT_DIR = '/var/www/continue/'
APP_PATH = os.path.join(PROJECT_DIR, 'app',).replace('\\', '/'),
sys.path.append(APP_PATH)
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' # also tried 'continue.settings', but same errors appears
# import django.core.handlers.wsgi
# application = django.core.handlers.wsgi.WSGIHandler()
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
But I am getting the following error Target WSGI script '/var/www/continue/django.wsgi' cannot be loaded as Python module in the log file
[Wed Feb 18 14:28:28.273972 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] mod_wsgi (pid=28781): Target WSGI script '/var/www/continue/django.wsgi' cannot be loaded as Python module.
[Wed Feb 18 14:28:28.274014 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] mod_wsgi (pid=28781): Exception occurred processing WSGI script '/var/www/continue/django.wsgi'.
[Wed Feb 18 14:28:28.274038 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] Traceback (most recent call last):
[Wed Feb 18 14:28:28.274060 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File "/var/www/continue/django.wsgi", line 18, in
[Wed Feb 18 14:28:28.274137 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] from django.core.wsgi import get_wsgi_application
[Wed Feb 18 14:28:28.274152 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File "/var/www/continue/env-continue/lib/python2.7/site-packages/django/core/wsgi.py", line 2, in
[Wed Feb 18 14:28:28.274174 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] from django.core.handlers.wsgi import WSGIHandler
[Wed Feb 18 14:28:28.274186 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File "/var/www/continue/env-continue/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 11, in
[Wed Feb 18 14:28:28.274211 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] from django import http
[Wed Feb 18 14:28:28.274229 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File "/var/www/continue/env-continue/lib/python2.7/site-packages/django/http/init.py", line 4, in
[Wed Feb 18 14:28:28.274253 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] from django.http.response import (HttpResponse, StreamingHttpResponse,
[Wed Feb 18 14:28:28.274279 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File "/var/www/continue/env-continue/lib/python2.7/site-packages/django/http/response.py", line 13, in
[Wed Feb 18 14:28:28.274298 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] from django.core.serializers.json import DjangoJSONEncoder
[Wed Feb 18 14:28:28.274310 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File "/var/www/continue/env-continue/lib/python2.7/site-packages/django/core/serializers/init.py", line 23, in
[Wed Feb 18 14:28:28.274328 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] from django.core.serializers.base import SerializerDoesNotExist
[Wed Feb 18 14:28:28.274340 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File "/var/www/continue/env-continue/lib/python2.7/site-packages/django/core/serializers/base.py", line 6, in
[Wed Feb 18 14:28:28.274357 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] from django.db import models
[Wed Feb 18 14:28:28.274368 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File "/var/www/continue/env-continue/lib/python2.7/site-packages/django/db/models/init.py", line 6, in
[Wed Feb 18 14:28:28.274387 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] from django.db.models.query import Q, QuerySet, Prefetch # NOQA
[Wed Feb 18 14:28:28.274404 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File "/var/www/continue/env-continue/lib/python2.7/site-packages/django/db/models/query.py", line 13, in
[Wed Feb 18 14:28:28.274435 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] from django.db.models.fields import AutoField, Empty
[Wed Feb 18 14:28:28.274454 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File "/var/www/continue/env-continue/lib/python2.7/site-packages/django/db/models/fields/init.py", line 15, in
[Wed Feb 18 14:28:28.274489 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] from django.db.models.lookups import default_lookups, RegisterLookupMixin
[Wed Feb 18 14:28:28.274505 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File "/var/www/continue/env-continue/lib/python2.7/site-packages/django/db/models/lookups.py", line 6, in
[Wed Feb 18 14:28:28.274525 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] from django.utils import timezone
[Wed Feb 18 14:28:28.274536 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File "/var/www/continue/env-continue/lib/python2.7/site-packages/django/utils/timezone.py", line 13, in
[Wed Feb 18 14:28:28.274554 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] import pytz
[Wed Feb 18 14:28:28.274565 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File "/var/www/continue/env-continue/lib/python2.7/site-packages/pytz/init.py", line 29, in
[Wed Feb 18 14:28:28.274583 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] from pkg_resources import resource_stream
[Wed Feb 18 14:28:28.274594 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File "/var/www/continue/env-continue/lib/python2.7/site-packages/pkg_resources.py", line 2829, in
[Wed Feb 18 14:28:28.274612 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] working_set = WorkingSet._build_master()
[Wed Feb 18 14:28:28.274622 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File "/var/www/continue/env-continue/lib/python2.7/site-packages/pkg_resources.py", line 440, in _build_master
[Wed Feb 18 14:28:28.274639 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] ws = cls()
[Wed Feb 18 14:28:28.274656 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File "/var/www/continue/env-continue/lib/python2.7/site-packages/pkg_resources.py", line 433, in init
[Wed Feb 18 14:28:28.274674 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] self.add_entry(entry)
[Wed Feb 18 14:28:28.274685 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File "/var/www/continue/env-continue/lib/python2.7/site-packages/pkg_resources.py", line 489, in add_entry
[Wed Feb 18 14:28:28.274701 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] for dist in find_distributions(entry, True):
[Wed Feb 18 14:28:28.274712 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File "/var/www/continue/env-continue/lib/python2.7/site-packages/pkg_resources.py", line 1817, in find_distributions
[Wed Feb 18 14:28:28.274728 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] importer = get_importer(path_item)
[Wed Feb 18 14:28:28.274739 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File "/usr/lib/python2.7/pkgutil.py", line 384, in get_importer
[Wed Feb 18 14:28:28.274756 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] importer = path_hook(path_item)
[Wed Feb 18 14:28:28.274775 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] TypeError: must be string, not tuple
I wonder what is going wrong?
Related
My Django app was working fine, but now I'm getting a server error, the last thing I did was a reboot to my Centos7 Server and now I'm getting this error:
and this are my logs I'm using apache:
[Thu Mar 30 14:04:10.571843 2017] [:error] [pid 11335] [remote 10.221.50.100:24] mod_wsgi (pid=11335): Target WSGI script '/opt/btsystem/BTSystem/wsgi.py' cannot be loaded as Python module.
[Thu Mar 30 14:04:10.571991 2017] [:error] [pid 11335] [remote 10.221.50.100:24] mod_wsgi (pid=11335): Exception occurred processing WSGI script '/opt/btsystem/BTSystem/wsgi.py'.
[Thu Mar 30 14:04:10.572263 2017] [:error] [pid 11335] [remote 10.221.50.100:24] Traceback (most recent call last):
[Thu Mar 30 14:04:10.572544 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/opt/btsystem/BTSystem/wsgi.py", line 16, in <module>
[Thu Mar 30 14:04:10.572795 2017] [:error] [pid 11335] [remote 10.221.50.100:24] application = get_wsgi_application()
[Thu Mar 30 14:04:10.572919 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Thu Mar 30 14:04:10.573054 2017] [:error] [pid 11335] [remote 10.221.50.100:24] django.setup(set_prefix=False)
[Thu Mar 30 14:04:10.573107 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/site-packages/django/__init__.py", line 22, in setup
[Thu Mar 30 14:04:10.573170 2017] [:error] [pid 11335] [remote 10.221.50.100:24] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Thu Mar 30 14:04:10.573261 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/site-packages/django/utils/log.py", line 75, in configure_logging
[Thu Mar 30 14:04:10.573312 2017] [:error] [pid 11335] [remote 10.221.50.100:24] logging_config_func(logging_settings)
[Thu Mar 30 14:04:10.573369 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/logging/config.py", line 803, in dictConfig
[Thu Mar 30 14:04:10.573409 2017] [:error] [pid 11335] [remote 10.221.50.100:24] dictConfigClass(config).configure()
[Thu Mar 30 14:04:10.573455 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/logging/config.py", line 585, in configure
[Thu Mar 30 14:04:10.573501 2017] [:error] [pid 11335] [remote 10.221.50.100:24] '%r: %s' % (name, e))
[Thu Mar 30 14:04:10.573567 2017] [:error] [pid 11335] [remote 10.221.50.100:24] ValueError: Unable to configure handler 'file': [Errno 13] Permission denied: '/opt/btsystem-logs/btsystem-debug.log'
Any idea?
The last line shows that Django doesn't have permission to write to the configured log file.
[Thu Mar 30 14:04:10.573567 2017] [:error] [pid 11335] [remote 10.221.50.100:24] ValueError: Unable to configure handler 'file': [Errno 13] Permission denied: '/opt/btsystem-logs/btsystem-debug.log'
Make sure the file /opt/btsystem-logs/btsystem-debug.log is writeable by the user running the Django server.
The main problem was that I needed to do the following to enable the virtual host from Apache:
firewall-cmd --get-active-zones
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
Needed to open the ports.
Im not sure what i am, doing wrong, when on my Django app, I run the app locally and it works fine with Amazon RDS. But when I deploy(eb deploy) then use (eb open) it doesn't work. It comes up with a 500 error. Any ideas on how i could fix this? Thanks!
This is the error in the logs:
[Fri Nov 18 11:08:32.441246 2016] [:error] [pid 10749] [remote 127.0.0.1:27580] apps.populate(settings.INSTALLED_APPS)
[Fri Nov 18 11:08:32.441251 2016] [:error] [pid 10749] [remote 127.0.0.1:27580] File "/opt/python/run/venv/lib/python2.7/site-packages/django/apps/registry.py", line 78, in populate
[Fri Nov 18 11:08:32.441261 2016] [:error] [pid 10749] [remote 127.0.0.1:27580] raise RuntimeError("populate() isn't reentrant")
[Fri Nov 18 11:08:32.441274 2016] [:error] [pid 10749] [remote 127.0.0.1:27580] RuntimeError: populate() isn't reentrant
[Fri Nov 18 11:08:33.444202 2016] [:error] [pid 10749] [remote 127.0.0.1:27580] mod_wsgi (pid=10749): Target WSGI script '/opt/python/current/app/hhh/wsgi.py' cannot be loaded as Python module.
[Fri Nov 18 11:08:33.444225 2016] [:error] [pid 10749] [remote 127.0.0.1:27580] mod_wsgi (pid=10749): Exception occurred processing WSGI script '/opt/python/current/app/hhh/wsgi.py'.
[Fri Nov 18 11:08:33.444239 2016] [:error] [pid 10749] [remote 127.0.0.1:27580] Traceback (most recent call last):
[Fri Nov 18 11:08:33.444254 2016] [:error] [pid 10749] [remote 127.0.0.1:27580] File "/opt/python/current/app/hhh/wsgi.py", line 16, in <module>
[Fri Nov 18 11:08:33.444279 2016] [:error] [pid 10749] [remote 127.0.0.1:27580] application = get_wsgi_application()
[Fri Nov 18 11:08:33.444287 2016] [:error] [pid 10749] [remote 127.0.0.1:27580] File "/opt/python/run/venv/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Fri Nov 18 11:08:33.444300 2016] [:error] [pid 10749] [remote 127.0.0.1:27580] django.setup()
[Fri Nov 18 11:08:33.444306 2016] [:error] [pid 10749] [remote 127.0.0.1:27580] File "/opt/python/run/venv/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
[Fri Nov 18 11:08:33.444315 2016] [:error] [pid 10749] [remote 127.0.0.1:27580] apps.populate(settings.INSTALLED_APPS)
[Fri Nov 18 11:08:33.444320 2016] [:error] [pid 10749] [remote 127.0.0.1:27580] File "/opt/python/run/venv/lib/python2.7/site-packages/django/apps/registry.py", line 78, in populate
[Fri Nov 18 11:08:33.444329 2016] [:error] [pid 10749] [remote 127.0.0.1:27580] raise RuntimeError("populate() isn't reentrant")
[Fri Nov 18 11:08:33.444342 2016] [:error] [pid 10749] [remote 127.0.0.1:27580] RuntimeError: populate() isn't reentrant
[Fri Nov 18 11:09:06.702445 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] mod_wsgi (pid=10749): Target WSGI script '/opt/python/current/app/hhh/wsgi.py' cannot be loaded as Python module.
[Fri Nov 18 11:09:06.702472 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] mod_wsgi (pid=10749): Exception occurred processing WSGI script '/opt/python/current/app/hhh/wsgi.py'.
[Fri Nov 18 11:09:06.702489 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] Traceback (most recent call last):
[Fri Nov 18 11:09:06.702506 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] File "/opt/python/current/app/hhh/wsgi.py", line 16, in <module>
[Fri Nov 18 11:09:06.702530 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] application = get_wsgi_application()
[Fri Nov 18 11:09:06.702538 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] File "/opt/python/run/venv/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Fri Nov 18 11:09:06.702551 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] django.setup()
[Fri Nov 18 11:09:06.702557 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] File "/opt/python/run/venv/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
[Fri Nov 18 11:09:06.702566 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] apps.populate(settings.INSTALLED_APPS)
[Fri Nov 18 11:09:06.702572 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] File "/opt/python/run/venv/lib/python2.7/site-packages/django/apps/registry.py", line 78, in populate
[Fri Nov 18 11:09:06.702582 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] raise RuntimeError("populate() isn't reentrant")
[Fri Nov 18 11:09:06.702595 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] RuntimeError: populate() isn't reentrant
[Fri Nov 18 11:12:26.190170 2016] [:error] [pid 10749] [remote 172.31.40.17:29884] mod_wsgi (pid=10749): Target WSGI script '/opt/python/current/app/hhh/wsgi.py' cannot be loaded as Python module.
[Fri Nov 18 11:12:26.190197 2016] [:error] [pid 10749] [remote 172.31.40.17:29884] mod_wsgi (pid=10749): Exception occurred processing WSGI script '/opt/python/current/app/hhh/wsgi.py'.
[Fri Nov 18 11:12:26.190232 2016] [:error] [pid 10749] [remote 172.31.40.17:29884] Traceback (most recent call last):
[Fri Nov 18 11:12:26.190249 2016] [:error] [pid 10749] [remote 172.31.40.17:29884] File "/opt/python/current/app/hhh/wsgi.py", line 16, in <module>
[Fri Nov 18 11:12:26.190272 2016] [:error] [pid 10749] [remote 172.31.40.17:29884] application = get_wsgi_application()
[Fri Nov 18 11:12:26.190280 2016] [:error] [pid 10749] [remote 172.31.40.17:29884] File "/opt/python/run/venv/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Fri Nov 18 11:12:26.190292 2016] [:error] [pid 10749] [remote 172.31.40.17:29884] django.setup()
[Fri Nov 18 11:12:26.190297 2016] [:error] [pid 10749] [remote 172.31.40.17:29884] File "/opt/python/run/venv/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
[Fri Nov 18 11:12:26.190305 2016] [:error] [pid 10749] [remote 172.31.40.17:29884] apps.populate(settings.INSTALLED_APPS)
[Fri Nov 18 11:12:26.190310 2016] [:error] [pid 10749] [remote 172.31.40.17:29884] File "/opt/python/run/venv/lib/python2.7/site-packages/django/apps/registry.py", line 78, in populate
[Fri Nov 18 11:12:26.190319 2016] [:error] [pid 10749] [remote 172.31.40.17:29884] raise RuntimeError("populate() isn't reentrant")
[Fri Nov 18 11:12:26.190331 2016] [:error] [pid 10749] [remote 172.31.40.17:29884] RuntimeError: populate() isn't reentrant
[Fri Nov 18 11:13:06.986835 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] mod_wsgi (pid=10749): Target WSGI script '/opt/python/current/app/hhh/wsgi.py' cannot be loaded as Python module.
[Fri Nov 18 11:13:06.986861 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] mod_wsgi (pid=10749): Exception occurred processing WSGI script '/opt/python/current/app/hhh/wsgi.py'.
[Fri Nov 18 11:13:06.986878 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] Traceback (most recent call last):
[Fri Nov 18 11:13:06.986895 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] File "/opt/python/current/app/hhh/wsgi.py", line 16, in <module>
[Fri Nov 18 11:13:06.986918 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] application = get_wsgi_application()
[Fri Nov 18 11:13:06.986926 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] File "/opt/python/run/venv/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Fri Nov 18 11:13:06.986939 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] django.setup()
[Fri Nov 18 11:13:06.986945 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] File "/opt/python/run/venv/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
[Fri Nov 18 11:13:06.986954 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] apps.populate(settings.INSTALLED_APPS)
[Fri Nov 18 11:13:06.986960 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] File "/opt/python/run/venv/lib/python2.7/site-packages/django/apps/registry.py", line 78, in populate
[Fri Nov 18 11:13:06.986969 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] raise RuntimeError("populate() isn't reentrant")
[Fri Nov 18 11:13:06.986982 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] RuntimeError: populate() isn't reentrant
[Fri Nov 18 11:13:32.432736 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] mod_wsgi (pid=10749): Target WSGI script '/opt/python/current/app/hhh/wsgi.py' cannot be loaded as Python module.
[Fri Nov 18 11:13:32.432761 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] mod_wsgi (pid=10749): Exception occurred processing WSGI script '/opt/python/current/app/hhh/wsgi.py'.
[Fri Nov 18 11:13:32.432777 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] Traceback (most recent call last):
[Fri Nov 18 11:13:32.432794 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] File "/opt/python/current/app/hhh/wsgi.py", line 16, in <module>
[Fri Nov 18 11:13:32.432821 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] application = get_wsgi_application()
[Fri Nov 18 11:13:32.432829 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] File "/opt/python/run/venv/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Fri Nov 18 11:13:32.432853 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] django.setup()
[Fri Nov 18 11:13:32.432859 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] File "/opt/python/run/venv/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
[Fri Nov 18 11:13:32.432868 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] apps.populate(settings.INSTALLED_APPS)
[Fri Nov 18 11:13:32.432873 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] File "/opt/python/run/venv/lib/python2.7/site-packages/django/apps/registry.py", line 78, in populate
[Fri Nov 18 11:13:32.432883 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] raise RuntimeError("populate() isn't reentrant")
[Fri Nov 18 11:13:32.432895 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] RuntimeError: populate() isn't reentrant
[Fri Nov 18 11:14:36.671161 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] mod_wsgi (pid=10749): Target WSGI script '/opt/python/current/app/hhh/wsgi.py' cannot be loaded as Python module.
[Fri Nov 18 11:14:36.671186 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] mod_wsgi (pid=10749): Exception occurred processing WSGI script '/opt/python/current/app/hhh/wsgi.py'.
[Fri Nov 18 11:14:36.671202 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] Traceback (most recent call last):
[Fri Nov 18 11:14:36.671218 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] File "/opt/python/current/app/hhh/wsgi.py", line 16, in <module>
[Fri Nov 18 11:14:36.671242 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] application = get_wsgi_application()
[Fri Nov 18 11:14:36.671250 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] File "/opt/python/run/venv/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Fri Nov 18 11:14:36.671262 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] django.setup()
[Fri Nov 18 11:14:36.671268 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] File "/opt/python/run/venv/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
[Fri Nov 18 11:14:36.671277 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] apps.populate(settings.INSTALLED_APPS)
[Fri Nov 18 11:14:36.671282 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] File "/opt/python/run/venv/lib/python2.7/site-packages/django/apps/registry.py", line 78, in populate
[Fri Nov 18 11:14:36.671292 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] raise RuntimeError("populate() isn't reentrant")
[Fri Nov 18 11:14:36.671304 2016] [:error] [pid 10749] [remote 172.31.40.17:31932] RuntimeError: populate() isn't reentrant
[Fri Nov 18 11:15:39.070645 2016] [:error] [pid 10749] [remote 172.31.40.17:27580] mod_wsgi (pid=10749): Target WSGI script '/opt/python/current/app/hhh/wsgi.py' cannot be loaded as Python module.
[Fri Nov 18 11:15:39.070671 2016] [:error] [pid 10749] [remote 172.31.40.17:27580] mod_wsgi (pid=10749): Exception occurred processing WSGI script '/opt/python/current/app/hhh/wsgi.py'.
[Fri Nov 18 11:15:39.070687 2016] [:error] [pid 10749] [remote 172.31.40.17:27580] Traceback (most recent call last):
[Fri Nov 18 11:15:39.070705 2016] [:error] [pid 10749] [remote 172.31.40.17:27580] File "/opt/python/current/app/hhh/wsgi.py", line 16, in <module>
[Fri Nov 18 11:15:39.070729 2016] [:error] [pid 10749] [remote 172.31.40.17:27580] application = get_wsgi_application()
[Fri Nov 18 11:15:39.070737 2016] [:error] [pid 10749] [remote 172.31.40.17:27580] File "/opt/python/run/venv/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Fri Nov 18 11:15:39.070749 2016] [:error] [pid 10749] [remote 172.31.40.17:27580] django.setup()
[Fri Nov 18 11:15:39.070755 2016] [:error] [pid 10749] [remote 172.31.40.17:27580] File "/opt/python/run/venv/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
[Fri Nov 18 11:15:39.070773 2016] [:error] [pid 10749] [remote 172.31.40.17:27580] apps.populate(settings.INSTALLED_APPS)
[Fri Nov 18 11:15:39.070779 2016] [:error] [pid 10749] [remote 172.31.40.17:27580] File "/opt/python/run/venv/lib/python2.7/site-packages/django/apps/registry.py", line 78, in populate
[Fri Nov 18 11:15:39.070788 2016] [:error] [pid 10749] [remote 172.31.40.17:27580] raise RuntimeError("populate() isn't reentrant")
[Fri Nov 18 11:15:39.070801 2016] [:error] [pid 10749] [remote 172.31.40.17:27580] RuntimeError: populate() isn't reentrant
[Fri Nov 18 11:16:05.684829 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] mod_wsgi (pid=10749): Target WSGI script '/opt/python/current/app/hhh/wsgi.py' cannot be loaded as Python module.
[Fri Nov 18 11:16:05.684853 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] mod_wsgi (pid=10749): Exception occurred processing WSGI script '/opt/python/current/app/hhh/wsgi.py'.
[Fri Nov 18 11:16:05.684868 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] Traceback (most recent call last):
[Fri Nov 18 11:16:05.684885 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] File "/opt/python/current/app/hhh/wsgi.py", line 16, in <module>
[Fri Nov 18 11:16:05.684908 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] application = get_wsgi_application()
[Fri Nov 18 11:16:05.684915 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] File "/opt/python/run/venv/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Fri Nov 18 11:16:05.684928 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] django.setup()
[Fri Nov 18 11:16:05.684934 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] File "/opt/python/run/venv/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
[Fri Nov 18 11:16:05.684943 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] apps.populate(settings.INSTALLED_APPS)
[Fri Nov 18 11:16:05.684949 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] File "/opt/python/run/venv/lib/python2.7/site-packages/django/apps/registry.py", line 78, in populate
[Fri Nov 18 11:16:05.684958 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] raise RuntimeError("populate() isn't reentrant")
[Fri Nov 18 11:16:05.684970 2016] [:error] [pid 10749] [remote 172.31.40.17:31676] RuntimeError: populate() isn't reentrant
Here is the WSGI file
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hhh.settings")
application = get_wsgi_application()
I am uploading a website to a Ubuntu 14.04 VPS for the first time. I am using Apache 2.4.7, mod_wsgi, and Django 1.8.5. I am getting a 500 Internal Server Error. I cannot figure out if the problem is in my wsgi file or configuration or my Django configuration.
Apache Error Log:
[Tue Dec 15 19:57:14.734974 2015] [mpm_event:notice] [pid 28996:tid 139939323643776] AH00491: caught SIGTERM, shutting down
[Tue Dec 15 19:57:15.751172 2015] [mpm_event:notice] [pid 29181:tid 139688285566848] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Tue Dec 15 19:57:15.751270 2015] [core:notice] [pid 29181:tid 139688285566848] AH00094: Command line: '/usr/sbin/apache2'
[Tue Dec 15 19:57:19.996550 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] mod_wsgi (pid=29185): Exception occurred processing WSGI script '/var/www/MYSITE/MYSITE/wsgi.py'.
[Tue Dec 15 19:57:19.996694 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] Traceback (most recent call last):
[Tue Dec 15 19:57:19.996935 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__
[Tue Dec 15 19:57:19.997146 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] self.load_middleware()
[Tue Dec 15 19:57:19.997163 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 45, in load_middleware
[Tue Dec 15 19:57:19.997291 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] mw_class = import_by_path(middleware_path)
[Tue Dec 15 19:57:19.997305 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py", line 26, in import_by_path
[Tue Dec 15 19:57:19.997361 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] sys.exc_info()[2])
[Tue Dec 15 19:57:19.997371 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py", line 21, in import_by_path
[Tue Dec 15 19:57:19.997384 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] module = import_module(module_path)
[Tue Dec 15 19:57:19.997389 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] File "/usr/lib/python2.7/dist-packages/django/utils/importlib.py", line 40, in import_module
[Tue Dec 15 19:57:19.997425 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] __import__(name)
[Tue Dec 15 19:57:19.997447 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] ImproperlyConfigured: Error importing module django.middleware.security: "No module named security"
[Tue Dec 15 19:57:20.201372 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] mod_wsgi (pid=29184): Exception occurred processing WSGI script '/var/www/MYSITE/MYSITE/wsgi.py'., referer: http://MY_IP/
[Tue Dec 15 19:57:20.201446 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] Traceback (most recent call last):, referer: http://MY_IP/
[Tue Dec 15 19:57:20.201468 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__, referer: http://MY_IP/
[Tue Dec 15 19:57:20.201575 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] self.load_middleware(), referer: http://MY_IP/
[Tue Dec 15 19:57:20.201587 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 45, in load_middleware, referer: http://MY_IP/
[Tue Dec 15 19:57:20.201699 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] mw_class = import_by_path(middleware_path), referer: http://MY_IP/
[Tue Dec 15 19:57:20.201713 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py", line 26, in import_by_path, referer: http://MY_IP/
[Tue Dec 15 19:57:20.201765 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] sys.exc_info()[2]), referer: http://MY_IP/
[Tue Dec 15 19:57:20.201775 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py", line 21, in import_by_path, referer: http://MY_IP/
[Tue Dec 15 19:57:20.201798 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] module = import_module(module_path), referer: http://MY_IP/
[Tue Dec 15 19:57:20.201806 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] File "/usr/lib/python2.7/dist-packages/django/utils/importlib.py", line 40, in import_module, referer: http://MY_IP/
[Tue Dec 15 19:57:20.201845 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] __import__(name), referer: http://MY_IP/
[Tue Dec 15 19:57:20.201869 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] ImproperlyConfigured: Error importing module django.middleware.security: "No module named security", referer: http://MY_IP/
[Tue Dec 15 19:57:22.650853 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] mod_wsgi (pid=29184): Exception occurred processing WSGI script '/var/www/MYSITE/MYSITE/wsgi.py'.
[Tue Dec 15 19:57:22.650936 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] Traceback (most recent call last):
[Tue Dec 15 19:57:22.650987 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__
[Tue Dec 15 19:57:22.651044 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] self.load_middleware()
[Tue Dec 15 19:57:22.651062 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 45, in load_middleware
[Tue Dec 15 19:57:22.651083 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] mw_class = import_by_path(middleware_path)
[Tue Dec 15 19:57:22.651094 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py", line 26, in import_by_path
[Tue Dec 15 19:57:22.651111 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] sys.exc_info()[2])
[Tue Dec 15 19:57:22.651119 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py", line 21, in import_by_path
[Tue Dec 15 19:57:22.651131 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] module = import_module(module_path)
[Tue Dec 15 19:57:22.651140 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] File "/usr/lib/python2.7/dist-packages/django/utils/importlib.py", line 40, in import_module
[Tue Dec 15 19:57:22.651154 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] __import__(name)
[Tue Dec 15 19:57:22.651184 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] ImproperlyConfigured: Error importing module django.middleware.security: "No module named security"
[Tue Dec 15 19:57:22.719625 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] mod_wsgi (pid=29184): Exception occurred processing WSGI script '/var/www/MYSITE/MYSITE/wsgi.py'., referer: http://MY_IP/
[Tue Dec 15 19:57:22.719704 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] Traceback (most recent call last):, referer: http://MY_IP/
[Tue Dec 15 19:57:22.719756 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__, referer: http://MY_IP/
[Tue Dec 15 19:57:22.719834 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] self.load_middleware(), referer: http://MY_IP/
[Tue Dec 15 19:57:22.719855 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 45, in load_middleware, referer: http://MY_IP/
[Tue Dec 15 19:57:22.719878 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] mw_class = import_by_path(middleware_path), referer: http://MY_IP/
[Tue Dec 15 19:57:22.719890 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py", line 26, in import_by_path, referer: http://MY_IP/
[Tue Dec 15 19:57:22.719911 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] sys.exc_info()[2]), referer: http://MY_IP/
[Tue Dec 15 19:57:22.719921 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py", line 21, in import_by_path, referer: http://MY_IP/
[Tue Dec 15 19:57:22.719958 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] module = import_module(module_path), referer: http://MY_IP/
[Tue Dec 15 19:57:22.719971 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] File "/usr/lib/python2.7/dist-packages/django/utils/importlib.py", line 40, in import_module, referer: http://MY_IP/
[Tue Dec 15 19:57:22.719989 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] __import__(name), referer: http://MY_IP/
[Tue Dec 15 19:57:22.720022 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] ImproperlyConfigured: Error importing module django.middleware.security: "No module named security", referer: http://MY_IP/
wsgi.py:
import os, sys
sys.path.append('/var/www/MYSITE')
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MYSITE.settings")
application = get_wsgi_application()
Apache Virtual Host:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port t$
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName MYSITEinc.com
ServerAlias www.MYSITEinc.com
ServerAdmin email#site.com
DocumentRoot /var/www/MYSITE
WSGIScriptAlias / /var/www/MYSITE/MYSITE/wsgi.py
<Directory /var/www/MYSITE/MYSITE>
Require all granted
</Directory>
Alias /static /var/www/MYSITE/static
<Directory /var/www/MYSITE/static>
Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
settings.py
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = ‘KEY’
DEBUG = False
CSRF_COOKIE_SECURE = False
SESSION_COOKIE_SECURE = False
ADMINS = ((‘Name’), ‘name#site.com’)
MANAGERS = ((‘Name’), ‘name#site.com’)
ALLOWED_HOSTS = [
‘IP_ADDRESS’, ‘MYSITE.com',
]
INSTALLED_APPS = (
'django_admin_bootstrapped',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'web',
'bootstrap3',
'feedparser',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)
ROOT_URLCONF = ‘MYSITE.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.static',
],
},
},
]
WSGI_APPLICATION = 'MYSITE.wsgi.application'
AUTH_USER_MODEL = 'web.User'
LOGIN_URL = '/login/'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'MYSITE',
'USER': 'root',
'PASSWORD': ‘PASSWORD’,
'HOST': ‘IP_ADDRESS’,
'PORT': '3306',
}
}
CONN_MAX_AGE = None
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'
STATIC_ROOT = '/Users/MYNAME/MYSITE/'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'MYSITE#gmail.com'
EMAIL_HOST_PASSWORD = ‘PASSWORD’
If anyone has suggestions or solutions, can you please post them?
I believe you have your middleware in the wrong order.
Try putting your session middleware BEFORE your auth middleware (error in your logs indicates this problem).
The Django documentation covers middleware ordering as well.
I'm trying to do the deploy at my project with django1.8, using apache 2.x and mod_wsgi, the structure of my project is (pd: mi proyect is in /var/www)
projectdjango
apps -- (my django-apps)
....
projectdjango
settings
local.py
staging.py
url.py
static
templates
....
manage.py
projectdjango.wsgi
the code I'm using for the httpd.conf is
<VirtualHost *:80>
ServerName projectdjango.com
DocumentRoot /var/www/projectdjango
<Directory /var/www/ >
Order allow,deny
Allow from all
</Directory>
WSGIDaemonProcess projectdjango.com processes=2 threads=15
WSGIProcessGroup projectdjango.com
WSGIScriptAlias / /var/www/projectdjango/projectdjango.wsgi
</VirtualHost>
and the code for projectdjango.wsgi is
import os
import sys
sys.path.append('/var/www')
sys.path.append('/var/www/projectdjango')
os.environ['DJANGO_SETTINGS_MODULE'] = 'projectdjango.settings.staging'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
error.log
[Thu Apr 23 16:44:48.540206 2015] [core:notice] [pid 21662:tid 140482308327296] AH00094: Command line: '/usr/sbin/apache2'
[Thu Apr 23 16:45:43.715053 2015] [mpm_event:notice] [pid 21662:tid 140482308327296] AH00491: caught SIGTERM, shutting down
[Thu Apr 23 16:45:44.907958 2015] [mpm_event:notice] [pid 21779:tid 140246657443712] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming n$
[Thu Apr 23 16:45:44.908339 2015] [core:notice] [pid 21779:tid 140246657443712] AH00094: Command line: '/usr/sbin/apache2'
[Thu Apr 23 16:48:31.071450 2015] [mpm_event:notice] [pid 21779:tid 140246657443712] AH00491: caught SIGTERM, shutting down
[Thu Apr 23 16:48:32.282889 2015] [mpm_event:notice] [pid 21909:tid 140394885306240] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming n$
[Thu Apr 23 16:48:32.283273 2015] [core:notice] [pid 21909:tid 140394885306240] AH00094: Command line: '/usr/sbin/apache2'
[Thu Apr 23 21:49:47.620133 2015] [:error] [pid 21911:tid 140394723014400] No handlers could be found for logger "django.request"
[Thu Apr 23 21:49:47.842564 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] mod_wsgi (pid=21911): Exception occurred processing WSGI script '/$
[Thu Apr 23 21:49:47.842699 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] Traceback (most recent call last):
[Thu Apr 23 21:49:47.842771 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] File "/usr/local/lib/python2.7/dist-packages/django/core/handler$
[Thu Apr 23 21:49:47.844350 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] response = self.get_response(request)
[Thu Apr 23 21:49:47.844455 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] File "/usr/local/lib/python2.7/dist-packages/django/core/handler$
[Thu Apr 23 21:49:47.844851 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] response = self.handle_uncaught_exception(request, resolver, s$
[Thu Apr 23 21:49:47.844904 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] File "/usr/local/lib/python2.7/dist-packages/django/core/handler$
[Thu Apr 23 21:49:47.844979 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] return debug.technical_500_response(request, *exc_info)
[Thu Apr 23 21:49:47.845023 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] File "/usr/local/lib/python2.7/dist-packages/django/views/debug.$
[Thu Apr 23 21:49:47.846871 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] html = reporter.get_traceback_html()
[Thu Apr 23 21:49:47.846981 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] File "/usr/local/lib/python2.7/dist-packages/django/views/debug.$
[Thu Apr 23 21:49:47.847070 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] return t.render(c)
[Thu Apr 23 21:49:47.847112 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] File "/usr/local/lib/python2.7/dist-packages/django/template/bas$
[Thu Apr 23 21:49:47.848209 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] return self._render(context)
[Thu Apr 23 21:49:47.848293 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] File "/usr/local/lib/python2.7/dist-packages/django/template/bas$
[Thu Apr 23 21:49:47.848394 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] return self.nodelist.render(context)
[Thu Apr 23 21:49:47.850682 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] File "/usr/local/lib/python2.7/dist-packages/django/utils/encodi$
[Thu Apr 23 21:49:47.851014 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] s = six.text_type(s)
[Thu Apr 23 21:49:47.851063 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] File "/usr/local/lib/python2.7/dist-packages/django/utils/functi$
[Thu Apr 23 21:49:47.851538 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] return func(*self.__args, **self.__kw)
[Thu Apr 23 21:49:47.851600 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] File "/usr/local/lib/python2.7/dist-packages/django/utils/transl$
[Thu Apr 23 21:49:47.851879 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] return _trans.ugettext(message)
[Thu Apr 23 21:49:47.851963 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] File "/usr/local/lib/python2.7/dist-packages/django/utils/transl$
[Thu Apr 23 21:49:47.852729 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] return do_translate(message, 'ugettext')
[Thu Apr 23 21:49:47.852805 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] File "/usr/local/lib/python2.7/dist-packages/django/utils/transl$
[Thu Apr 23 21:49:47.852891 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] _default = _default or translation(settings.LANGUAGE_CODE)
[Thu Apr 23 21:49:47.852933 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] File "/usr/local/lib/python2.7/dist-packages/django/utils/transl$
[Thu Apr 23 21:49:47.852997 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] _translations[language] = DjangoTranslation(language)
[Thu Apr 23 21:49:47.853037 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] File "/usr/local/lib/python2.7/dist-packages/django/utils/transl$
[Thu Apr 23 21:49:47.853102 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] self._add_installed_apps_translations()
[Thu Apr 23 21:49:47.853143 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] File "/usr/local/lib/python2.7/dist-packages/django/utils/transl$
[Thu Apr 23 21:49:47.853208 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] "The translation infrastructure cannot be initialized before t$
[Thu Apr 23 21:49:47.853392 2015] [:error] [pid 21911:tid 140394723014400] [remote 127.0.0.1:16955] AppRegistryNotReady: The translation infrastructure cannot be init$
I hope someone can help me what i'm doing wrong
I'm trying to configure the WSGI in Apache to work with Django but it's not working, when I go to domain.com it gives me an error 500.
But If I start Django using:
python manage.py runserver domain.com:8000
When I go to domain.com:8000 works perfectly so I think It's something about apache and WSGI.
Here you have my WSGI script:
import os
import sys
sys.path.append('/var/www/domain/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'domain.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
My VirtualHost configuration:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName www.domain.com
ServerAdmin info#domain.com
ServerAlias domain.com
DocumentRoot /var/www/domain
WSGIScriptAlias / /var/www/domain/domain.wsgi
#Alias /static/ /var/www/domain/static/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
I'm using Ubuntu 14.04. I tried looking at logs but I have no idea what's wrong.
Logs:
[Thu Sep 25 10:15:09.549670 2014] [:error] [pid 17141] [client 88.12.185.72:65477] mod_wsgi (pid=17141): Exception occurred processing WSGI script '/var/www/domain/domain.wsgi'.
[Thu Sep 25 10:15:09.549722 2014] [:error] [pid 17141] [client 88.12.185.72:65477] Traceback (most recent call last):
[Thu Sep 25 10:15:09.549747 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__
[Thu Sep 25 10:15:09.549880 2014] [:error] [pid 17141] [client 88.12.185.72:65477] response = self.get_response(request)
[Thu Sep 25 10:15:09.549899 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 199, in get_response
[Thu Sep 25 10:15:09.550029 2014] [:error] [pid 17141] [client 88.12.185.72:65477] response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Thu Sep 25 10:15:09.550048 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 236, in handle_uncaught_exception
[Thu Sep 25 10:15:09.550075 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return debug.technical_500_response(request, *exc_info)
[Thu Sep 25 10:15:09.550091 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 91, in technical_500_response
[Thu Sep 25 10:15:09.550492 2014] [:error] [pid 17141] [client 88.12.185.72:65477] html = reporter.get_traceback_html()
[Thu Sep 25 10:15:09.550513 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 350, in get_traceback_html
[Thu Sep 25 10:15:09.550539 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return t.render(c)
[Thu Sep 25 10:15:09.550554 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 148, in render
[Thu Sep 25 10:15:09.550984 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return self._render(context)
[Thu Sep 25 10:15:09.551006 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 142, in _render
[Thu Sep 25 10:15:09.551034 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return self.nodelist.render(context)
[Thu Sep 25 10:15:09.551048 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 844, in render
[Thu Sep 25 10:15:09.551071 2014] [:error] [pid 17141] [client 88.12.185.72:65477] bit = self.render_node(node, context)
[Thu Sep 25 10:15:09.551084 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 80, in render_node
[Thu Sep 25 10:15:09.551174 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return node.render(context)
[Thu Sep 25 10:15:09.551192 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 90, in render
[Thu Sep 25 10:15:09.551217 2014] [:error] [pid 17141] [client 88.12.185.72:65477] output = self.filter_expression.resolve(context)
[Thu Sep 25 10:15:09.551231 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 624, in resolve
[Thu Sep 25 10:15:09.551268 2014] [:error] [pid 17141] [client 88.12.185.72:65477] new_obj = func(obj, *arg_vals)
[Thu Sep 25 10:15:09.551284 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/defaultfilters.py", line 769, in date
[Thu Sep 25 10:15:09.551595 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return format(value, arg)
[Thu Sep 25 10:15:09.551615 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 343, in format
[Thu Sep 25 10:15:09.551759 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return df.format(format_string)
[Thu Sep 25 10:15:09.551778 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 35, in format
[Thu Sep 25 10:15:09.551817 2014] [:error] [pid 17141] [client 88.12.185.72:65477] pieces.append(force_text(getattr(self, piece)()))
[Thu Sep 25 10:15:09.551834 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 268, in r
[Thu Sep 25 10:15:09.551857 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return self.format('D, j M Y H:i:s O')
[Thu Sep 25 10:15:09.551871 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 35, in format
[Thu Sep 25 10:15:09.551892 2014] [:error] [pid 17141] [client 88.12.185.72:65477] pieces.append(force_text(getattr(self, piece)()))
[Thu Sep 25 10:15:09.551907 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/encoding.py", line 85, in force_text
[Thu Sep 25 10:15:09.552021 2014] [:error] [pid 17141] [client 88.12.185.72:65477] s = six.text_type(s)
[Thu Sep 25 10:15:09.552039 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 144, in __text_cast
[Thu Sep 25 10:15:09.552276 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return func(*self.__args, **self.__kw)
[Thu Sep 25 10:15:09.552297 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py", line 83, in ugettext
[Thu Sep 25 10:15:09.552412 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return _trans.ugettext(message)
[Thu Sep 25 10:15:09.552431 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 325, in ugettext
[Thu Sep 25 10:15:09.552686 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return do_translate(message, 'ugettext')
[Thu Sep 25 10:15:09.552706 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 306, in do_translate
[Thu Sep 25 10:15:09.552731 2014] [:error] [pid 17141] [client 88.12.185.72:65477] _default = translation(settings.LANGUAGE_CODE)
[Thu Sep 25 10:15:09.552746 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 209, in translation
[Thu Sep 25 10:15:09.552768 2014] [:error] [pid 17141] [client 88.12.185.72:65477] default_translation = _fetch(settings.LANGUAGE_CODE)
[Thu Sep 25 10:15:09.552782 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 189, in _fetch
[Thu Sep 25 10:15:09.552804 2014] [:error] [pid 17141] [client 88.12.185.72:65477] "The translation infrastructure cannot be initialized before the "
[Thu Sep 25 10:15:09.552830 2014] [:error] [pid 17141] [client 88.12.185.72:65477] AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time.
Anyone knows what I'm doing wrong?
Thanks
I discover that the version of Django in my production server is 1.7.0 and in Development server is 1.6.4. After downgrade Django works fine.
sudo pip install django==1.6.4