I am trying to deploy django website.Project name is pom.
I am trying to run django website in ec2 server using apache2 and getting the following error:
Apache error file:
[Fri Jul 24 12:37:33.621285 2015] [:info] [pid 20446:tid 140024755709824] mod_wsgi (pid=20446): Attach interpreter ''.
[Fri Jul 24 12:37:33.621462 2015] [:info] [pid 20446:tid 140024755709824] mod_wsgi (pid=20446): Adding '/home/ubuntu/.virtualenvs/edusamosa/lib/python2.7/site-packages/' to path.
[Fri Jul 24 12:37:44.145762 2015] [authz_core:debug] [pid 20448:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11934] AH01626: authorization result of Require all granted: granted
[Fri Jul 24 12:37:44.145888 2015] [authz_core:debug] [pid 20448:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11934] AH01626: authorization result of <RequireAny>: granted
[Fri Jul 24 12:37:44.145947 2015] [authz_core:debug] [pid 20448:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11934] AH01626: authorization result of Require all granted: granted
[Fri Jul 24 12:37:44.145953 2015] [authz_core:debug] [pid 20448:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11934] AH01626: authorization result of <RequireAny>: granted
[Fri Jul 24 12:37:44.152795 2015] [:info] [pid 20446:tid 140024564070144] mod_wsgi (pid=20446): Create interpreter 'www.edusamosa.in|'.
[Fri Jul 24 12:37:44.153592 2015] [:info] [pid 20446:tid 140024564070144] mod_wsgi (pid=20446): Adding '/home/ubuntu/.virtualenvs/edusamosa/lib/python2.7/site-packages/' to path.
[Fri Jul 24 12:37:44.152795 2015] [:info] [pid 20446:tid 140024564070144] mod_wsgi (pid=20446): Create interpreter 'www.edusamosa.in|'.
[Fri Jul 24 12:37:44.153592 2015] [:info] [pid 20446:tid 140024564070144] mod_wsgi (pid=20446): Adding '/home/ubuntu/.virtualenvs/edusamosa/lib/python2.7/site-packages/' to path.
[Fri Jul 24 12:37:44.153884 2015] [:info] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] mod_wsgi (pid=20446, process='pom', application='www.edusamosa.in|'): Loading WSGI script '/home/ubuntu/pom/pom/wsgi.py'.
[Fri Jul 24 12:37:44.354165 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] mod_wsgi (pid=20446): Target WSGI script '/home/ubuntu/pom/pom/wsgi.py' cannot be loaded as Python module.
[Fri Jul 24 12:37:44.354189 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] mod_wsgi (pid=20446): Exception occurred processing WSGI script '/home/ubuntu/pom/pom/wsgi.py'.
[Fri Jul 24 12:37:44.354222 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] Traceback (most recent call last):
[Fri Jul 24 12:37:44.354238 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] File "/home/ubuntu/pom/pom/wsgi.py", line 19, in <module>
[Fri Jul 24 12:37:44.354362 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] application = get_wsgi_application()
# [Fri Jul 24 12:37:44.354238 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] File "/home/ubuntu/pom/pom/wsgi.py", line 19, in <module>
[Fri Jul 24 12:37:44.354362 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] application = get_wsgi_application()
[Fri Jul 24 12:37:44.354377 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Fri Jul 24 12:37:44.354416 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] django.setup()
[Fri Jul 24 12:37:44.354428 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
[Fri Jul 24 12:37:44.354465 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] apps.populate(settings.INSTALLED_APPS)
[Fri Jul 24 12:37:44.354476 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 85, in populate
[Fri Jul 24 12:37:44.354590 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] app_config = AppConfig.create(entry)
[Fri Jul 24 12:37:44.354602 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 86, in create
[Fri Jul 24 12:37:44.354590 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] app_config = AppConfig.create(entry)
[Fri Jul 24 12:37:44.354602 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 86, in create
[Fri Jul 24 12:37:44.354697 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] module = import_module(entry)
[Fri Jul 24 12:37:44.354708 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[Fri Jul 24 12:37:44.354765 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] __import__(name)
[Fri Jul 24 12:37:44.354793 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] ImportError: No module named allauth
[Fri Jul 24 12:37:45.251341 2015] [authz_core:debug] [pid 20447:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11938] AH01626: authorization result of Require all granted: granted, referer: http://edusamosa.in/
[Fri Jul 24 12:37:45.251496 2015] [authz_core:debug] [pid 20447:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11938] AH01626: authorization result of <RequireAny>: granted, referer: http://edusamosa.in/
[Fri Jul 24 12:37:45.251559 2015] [authz_core:debug] [pid 20447:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11938] AH01626: authorization result of Require all granted: granted, referer: http://edusamosa.in/
[Fri Jul 24 12:37:45.251496 2015] [authz_core:debug] [pid 20447:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11938] AH01626: authorization result of <RequireAny>: granted, referer: http://edusamosa.in/
[Fri Jul 24 12:37:45.251559 2015] [authz_core:debug] [pid 20447:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11938] AH01626: authorization result of Require all granted: granted, referer: http://edusamosa.in/
[Fri Jul 24 12:37:45.251565 2015] [authz_core:debug] [pid 20447:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11938] AH01626: authorization result of <RequireAny>: granted, referer: http://edusamosa.in/
[Fri Jul 24 18:07:45.251722 2015] [:info] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] mod_wsgi (pid=20446, process='pom', application='www.edusamosa.in|'): Loading WSGI script '/home/ubuntu/pom/pom/wsgi.py'.
[Fri Jul 24 18:07:45.252817 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] mod_wsgi (pid=20446): Target WSGI script '/home/ubuntu/pom/pom/wsgi.py' cannot be loaded as Python module.
[Fri Jul 24 18:07:45.252831 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] mod_wsgi (pid=20446): Exception occurred processing WSGI script '/home/ubuntu/pom/pom/wsgi.py'.
[Fri Jul 24 18:07:45.252850 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] Traceback (most recent call last):
[Fri Jul 24 18:07:45.252870 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] File "/home/ubuntu/pom/pom/wsgi.py", line 19, in <module>
[Fri Jul 24 18:07:45.252850 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] Traceback (most recent call last):
[Fri Jul 24 18:07:45.252870 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] File "/home/ubuntu/pom/pom/wsgi.py", line 19, in <module>
[Fri Jul 24 18:07:45.252913 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] application = get_wsgi_application()
[Fri Jul 24 18:07:45.252923 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Fri Jul 24 18:07:45.252940 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] django.setup()
[Fri Jul 24 18:07:45.252948 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
[Fri Jul 24 18:07:45.252961 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] apps.populate(settings.INSTALLED_APPS)
[Fri Jul 24 18:07:45.252969 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 78, in populate
[Fri Jul 24 18:07:45.252981 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] raise RuntimeError("populate() isn't reentrant")
#
# [Fri Jul 24 18:07:45.252969 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 78, in populate
[Fri Jul 24 18:07:45.252981 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] raise RuntimeError("populate() isn't reentrant")
[Fri Jul 24 18:07:45.252996 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] RuntimeError: populate() isn't reentrant
~
My pom.settings.py is as follow:
"""
Django settings for pom project.
Generated by 'django-admin startproject' using Django 1.8.2.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
ALLOWED_HOSTS = ['*']
# Application definition
'''
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
# other finders..
# 'compressor.finders.CompressorFinder',
)
'''
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog',
'ckeditor',
'reviewandrating',
'links',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.linkedin',
'import_export',
'haystack',
'mathfilters',
)
# Ankur's Setting.py
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
"django.core.context_processors.request",
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.request',
'allauth.account.context_processors.account',
)
SITE_ID = 3
AUTH_PROFILE_MODULE = 'links.UserProfile'
LOGIN_URL = '/'
SOCIALACCOUNT_ADAPTER = 'links.my_adapter.MyAdapter'
SOCIALACCOUNT_QUERY_EMAIL = True
SOCIALACCOUNT_PROVIDERS = {
'facebook': {
'SCOPE': ['email'],
'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
'METHOD': 'js_sdk',
'VERIFIED_EMAIL': False
},
'google':
{'SCOPE': ['profile', 'email'],
'AUTH_PARAMS': {'access_type': 'online'}},
'linkedin':
{'SCOPE': ['r_emailaddress'],
'PROFILE_FIELDS': ['id',
'first-name',
'last-name',
'email-address',
'picture-url',
'public-profile-url']}
}
LOGIN_REDIRECT_URL = '/'
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 = 'pom.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['/home/ubuntu/pom/templates/'], # This is where you add the template directory
'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',
'allauth.account.context_processors.account',
'allauth.socialaccount.context_processors.socialaccount',
],
},
},
]
WSGI_APPLICATION = 'pom.wsgi.application'
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
'URL': 'http://localhost:8983/solr/',
'TIMEOUT': 60 * 5,
'INCLUDE_SPELLING': True,
'BATCH_SIZE': 100,
'EXCLUDED_INDEXES': ['thirdpartyapp.search_indexes.BarIndex'],
}
}
# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'hidden',
'USER': 'ubuntu',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': '3306',
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Asia/Kolkata'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_URL = '/static/'
STATICFILES_DIRS = (
'',
'/home/ubuntu/pom/static/img/',
'/home/ubuntu/pom/static/css/',
'/home/ubuntu/pom/static/js/',
)
# TEMPLATE_LOADERS = (
# 'django.template.loaders.filesystem.Loader',
# 'django.template.loaders.app_directories.Loader',
# #django.template.loaders.eggs.Loader',
# )
TEMPLATE_DIRS = (
# os.path.join(BASE_DIR, 'templates'),
'/home/ubuntu/pom/templates/',
)
CKEDITOR_CONFIGS = {
'default': {
'toolbar': 'full',
'height': 300,
'width': 900,
},
}
CKEDITOR_UPLOAD_PATH = "uploads/"
CKEDITOR_IMAGE_BACKEND = 'Pillow'
CKEDITOR_JQUERY_URL = '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'
STATIC_ROOT = '/home/ubuntu/pom/static/'
MEDIA_ROOT = '/home/ubuntu/pom/media/'
MEDIA_URL = '/media/'
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
The wsgi.py file is as follows:
"""
WSGI config for pom project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
import sys
from os.path import abspath, dirname, join
#sys.path.insert(0, '/home/ubuntu/deploy/pom')
sys.path.insert(0, abspath(join(dirname(__file__), "../")))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pom.settings")
application = get_wsgi_application()
The error messages clearly says:
ImportError: No module named allauth
The populate() not reentrant error is an error that occurs when mod_wsgi attempts to reload the WSGI script file, after the first error, and finds that Django was half initialised due to first error and so it gives up.
Fix the issue with allauth module not being found and the latter error should go away.
Related
Our issue is stemming from a Django project finding the corsheaders module running via Apache/WSGI. The code runs fine using the Django's local runserver but throws a 500 Internal Server Error when acccessed throught Apache (v.2.4.41). If we comment out the application and middleware in settings.py, the site and other code works fine (execpt the API functionality that needs corsheaders).
We have exhausted the online resources we can find, so thank you in advance for the advice to uninstall and reinstall django-cors-headers in a variety of ways using pip. We do use several other modules that have been installed via this gateway with no issue. The best we can tell, the issue stems from the django wsgi not seeing the module.
I included the relevant logs and settings below. I also noted the install locations for the corsheader module.
Relevant Versions
django-cors-headers==3.13.0 (installed at: /home/geekfest/.local/lib/python3.8/site-packages)
django-cors-middleware==1.5.0
python==3.8.10
Django==4.1.2
Ubuntu==20.04.1
pythonpath: ['', '/usr/lib/python38.zip', '/usr/lib/python3.8',
'/usr/lib/python3.8/lib-dynload',
'/home/geekfest/.local/lib/python3.8/site-packages',
'/usr/local/lib/python3.8/dist-packages',
'/usr/lib/python3/dist-packages']
**settings.py**
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'corsheaders',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'stats',
]
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.common.CommonMiddleware',
'stats.middleware.EventData',
]
ROOT_URLCONF = 'geekstats.urls'
CORS_ORIGIN_ALLOW_ALL = True
error.log
[Fri Oct 07 11:01:49.957188 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61279] mod_wsgi (pid=11860): Failed to exec Python script file '/home/geekfest/geekstats/csgo-geekstats/gee>
[Fri Oct 07 11:01:49.957302 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61279] mod_wsgi (pid=11860): Exception occurred processing WSGI script '/home/geekfest/geekstats/csgo-geeks>
[Fri Oct 07 11:01:49.960516 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61279] Traceback (most recent call last):
[Fri Oct 07 11:01:49.960613 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61279] File "/home/geekfest/geekstats/csgo-geekstats/geekstats/geekstats/wsgi.py", line 20, in <module>
[Fri Oct 07 11:01:49.960625 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61279] application = get_wsgi_application()
[Fri Oct 07 11:01:49.960633 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61279] File "/usr/lib/python3/dist-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Fri Oct 07 11:01:49.960637 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61279] django.setup(set_prefix=False)
[Fri Oct 07 11:01:49.960645 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61279] File "/usr/lib/python3/dist-packages/django/__init__.py", line 24, in setup
[Fri Oct 07 11:01:49.960651 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61279] apps.populate(settings.INSTALLED_APPS)
[Fri Oct 07 11:01:49.960674 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61279] File "/usr/lib/python3/dist-packages/django/apps/registry.py", line 91, in populate
[Fri Oct 07 11:01:49.960680 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61279] app_config = AppConfig.create(entry)
[Fri Oct 07 11:01:49.960690 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61279] File "/usr/lib/python3/dist-packages/django/apps/config.py", line 90, in create
[Fri Oct 07 11:01:49.960695 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61279] module = import_module(entry)
[Fri Oct 07 11:01:49.960721 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61279] File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
[Fri Oct 07 11:01:49.960726 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61279] return _bootstrap._gcd_import(name[level:], package, level)
[Fri Oct 07 11:01:49.960735 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61279] File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
[Fri Oct 07 11:01:49.960742 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61279] File "<frozen importlib._bootstrap>", line 991, in _find_and_load
[Fri Oct 07 11:01:49.960748 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61279] File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
[Fri Oct 07 11:01:49.960770 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61279] ModuleNotFoundError: No module named 'corsheaders'
[Fri Oct 07 11:01:50.241210 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61280] mod_wsgi (pid=11860): Failed to exec Python script file '/home/geekfest/geekstats/csgo-geekstats/gee>
[Fri Oct 07 11:01:50.241287 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61280] mod_wsgi (pid=11860): Exception occurred processing WSGI script '/home/geekfest/geekstats/csgo-geeks>
[Fri Oct 07 11:01:50.241442 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61280] Traceback (most recent call last):
[Fri Oct 07 11:01:50.241482 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61280] File "/home/geekfest/geekstats/csgo-geekstats/geekstats/geekstats/wsgi.py", line 20, in <module>
[Fri Oct 07 11:01:50.241486 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61280] application = get_wsgi_application()
[Fri Oct 07 11:01:50.241494 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61280] File "/usr/lib/python3/dist-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Fri Oct 07 11:01:50.241497 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61280] django.setup(set_prefix=False)
[Fri Oct 07 11:01:50.241504 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61280] File "/usr/lib/python3/dist-packages/django/__init__.py", line 24, in setup
[Fri Oct 07 11:01:50.241506 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61280] apps.populate(settings.INSTALLED_APPS)
[Fri Oct 07 11:01:50.241513 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61280] File "/usr/lib/python3/dist-packages/django/apps/registry.py", line 83, in populate
[Fri Oct 07 11:01:50.241516 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61280] raise RuntimeError("populate() isn't reentrant")
[Fri Oct 07 11:01:50.241532 2022] [wsgi:error] [pid 11860] [remote 108.41.247.85:61280] RuntimeError: populate() isn't reentrant
wsgi.py:
import os,sys
sys.path.append('/home/geekfest/geekstats/.../geekstats')
sys.path.append('/usr/lib/python3/dist-packages')
sys.path.append('/home/geekfest/.local/lib/python3.8/site-packages')
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'geekstats.settings')
application = get_wsgi_application()
Apache .conf virtual host definition:
<VirtualHost *:80>
ServerName xxx.com
ServerAlias stats.xxx.com
DocumentRoot /home/geekfest/.../geekstats/stats
ErrorLog ${APACHE_LOG_DIR}/gferror.log
CustomLog ${APACHE_LOG_DIR}/gfaccess.log combined
WSGIDaemonProcess xxx.com python-path=/usr/lib/python3.8:/home/geekfest/geekstats/...geekstats/geekstats:/usr/lib/python3/dist-packages:/home/geekfest/.local/lib/python3.8/site-packages
WSGIProcessGroup xxx.com
# Tell Apache what it should call when the “xxx” url alias is called
WSGIScriptAlias / /home/geekfest/.../geekstats/geekstats/wsgi.py
# Tell Apache where to find the “static” subdir for the django site
Alias /static /home/geekfest/.../stats/static
# Give Apache the location and permissions to where the wsgi.py file resides in>
<Directory /home/geekfest/.../geekstats/geekstats>
<Files wsgi.py>
Require all granted
Options +Indexes +ExecCGI
</Files>
</Directory>
# Give Apache the location and permissions to the static directory (images) for>
<Directory /home/geekfest/.../stats/static>
Order deny,allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
Make sure you have installed coreheaders. To install it you can try pip install django-cors-headers. If you are using virtualenv for python packages then you have to specify in the apache configuration file where your virtualenv is located.
Ok, so I figured it out. I knew it had to be path challenge because the module WAS there. If you look above, you will pip installed it to /home. WSGI was working from the /user directory. Once I forced Django to tell me where my other working libraries were, I saw the issue and force installed the library to /user.
The command to direct pip to force reinstall another directoy is:
sudo pip install --upgrade --force-reinstall --target /usr/lib/python3/dist-packages/ django-cors-headers
I'm trying to deploy a python web app using django and have successfully setup the EB environment but for some reason, it's not using my requirements.txt file to install the required modules (django and pytz). I see no reference to an invalid requirements.txt so I don't think that's the issue. Here is a file hierarchy and the latest log.
FirstWebApp/
.elasticbeanstalk/
config.yml
mysite/
#..
polls/
#..
db.sqlite3
manage.py
requirements.txt
[Sat Sep 01 21:08:01.508757 2018] [mpm_prefork:notice] [pid 7866] AH00169: caught SIGTERM, shutting down
[Sat Sep 01 21:08:02.599699 2018] [suexec:notice] [pid 11160] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Sat Sep 01 21:08:02.615594 2018] [so:warn] [pid 11160] AH01574: module wsgi_module is already loaded, skipping
[Sat Sep 01 21:08:02.617699 2018] [http2:warn] [pid 11160] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
[Sat Sep 01 21:08:02.617712 2018] [http2:warn] [pid 11160] AH02951: mod_ssl does not seem to be enabled
[Sat Sep 01 21:08:02.618263 2018] [lbmethod_heartbeat:notice] [pid 11160] AH02282: No slotmem from mod_heartmonitor
[Sat Sep 01 21:08:02.618326 2018] [:warn] [pid 11160] mod_wsgi: Compiled for Python/3.6.2.
[Sat Sep 01 21:08:02.618331 2018] [:warn] [pid 11160] mod_wsgi: Runtime using Python/3.6.5.
[Sat Sep 01 21:08:02.620634 2018] [mpm_prefork:notice] [pid 11160] AH00163: Apache/2.4.33 (Amazon) mod_wsgi/3.5 Python/3.6.5 configured -- resuming normal operations
[Sat Sep 01 21:08:02.620651 2018] [core:notice] [pid 11160] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sat Sep 01 21:08:05.381076 2018] [:error] [pid 11165] [remote 127.0.0.1:0] mod_wsgi (pid=11165): Target WSGI script '/opt/python/current/app/mysite/wsgi.py' cannot be loaded as Python module.
[Sat Sep 01 21:08:05.381116 2018] [:error] [pid 11165] [remote 127.0.0.1:0] mod_wsgi (pid=11165): Exception occurred processing WSGI script '/opt/python/current/app/mysite/wsgi.py'.
[Sat Sep 01 21:08:05.381287 2018] [:error] [pid 11165] [remote 127.0.0.1:0] Traceback (most recent call last):
[Sat Sep 01 21:08:05.381309 2018] [:error] [pid 11165] [remote 127.0.0.1:0] File "/opt/python/current/app/mysite/wsgi.py", line 12, in <module>
[Sat Sep 01 21:08:05.381313 2018] [:error] [pid 11165] [remote 127.0.0.1:0] from django.core.wsgi import get_wsgi_application
[Sat Sep 01 21:08:05.381326 2018] [:error] [pid 11165] [remote 127.0.0.1:0] ModuleNotFoundError: No module named 'django'
[Sat Sep 01 21:08:06.384353 2018] [:error] [pid 11165] [remote 127.0.0.1:252] mod_wsgi (pid=11165): Target WSGI script '/opt/python/current/app/mysite/wsgi.py' cannot be loaded as Python module.
[Sat Sep 01 21:08:06.384403 2018] [:error] [pid 11165] [remote 127.0.0.1:252] mod_wsgi (pid=11165): Exception occurred processing WSGI script '/opt/python/current/app/mysite/wsgi.py'.
[Sat Sep 01 21:08:06.384505 2018] [:error] [pid 11165] [remote 127.0.0.1:252] Traceback (most recent call last):
[Sat Sep 01 21:08:06.384528 2018] [:error] [pid 11165] [remote 127.0.0.1:252] File "/opt/python/current/app/mysite/wsgi.py", line 12, in <module>
[Sat Sep 01 21:08:06.384531 2018] [:error] [pid 11165] [remote 127.0.0.1:252] from django.core.wsgi import get_wsgi_application
[Sat Sep 01 21:08:06.384560 2018] [:error] [pid 11165] [remote 127.0.0.1:252] ModuleNotFoundError: No module named 'django'
[Sat Sep 01 21:08:07.387609 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] mod_wsgi (pid=11165): Target WSGI script '/opt/python/current/app/mysite/wsgi.py' cannot be loaded as Python module.
[Sat Sep 01 21:08:07.387656 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] mod_wsgi (pid=11165): Exception occurred processing WSGI script '/opt/python/current/app/mysite/wsgi.py'.
[Sat Sep 01 21:08:07.387725 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] Traceback (most recent call last):
[Sat Sep 01 21:08:07.387744 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] File "/opt/python/current/app/mysite/wsgi.py", line 12, in <module>
[Sat Sep 01 21:08:07.387748 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] from django.core.wsgi import get_wsgi_application
[Sat Sep 01 21:08:07.387761 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] ModuleNotFoundError: No module named 'django'
[Sat Sep 01 21:08:08.390656 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] mod_wsgi (pid=11165): Target WSGI script '/opt/python/current/app/mysite/wsgi.py' cannot be loaded as Python module.
[Sat Sep 01 21:08:08.390700 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] mod_wsgi (pid=11165): Exception occurred processing WSGI script '/opt/python/current/app/mysite/wsgi.py'.
[Sat Sep 01 21:08:08.390770 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] Traceback (most recent call last):
[Sat Sep 01 21:08:08.390790 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] File "/opt/python/current/app/mysite/wsgi.py", line 12, in <module>
[Sat Sep 01 21:08:08.390793 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] from django.core.wsgi import get_wsgi_application
[Sat Sep 01 21:08:08.390807 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] ModuleNotFoundError: No module named 'django'
I just had to commit the requirements.txt file. Django only looks at whatever files have been committed.
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.
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