I developed a platform with django + wsgi + pypy + postgresql + postgis, everything works fine in development environment, but in production it sends error 500 and in the apache log it says ImproperlyConfigured: Error loading psycopg2 module: No module named cffi
my config apache:
<VirtualHost *:80>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
WSGIScriptAlias / /home/user/plataform/project/project/wsgi.py
WSGIDaemonProcess project python-path=/home/user/plataform/project:/home/user/env/site-packages
WSGIProcessGroup project
WSGIPassAuthorization On
<Directory /home/user/plataform/project/project>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /media /home/user/plataform/project/media/
Alias /static /home/user/plataform/project/static/
<Directory /home/user/plataform/project/static>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /home/user/plataform/project/media>
Require all granted
</Directory>
my pip freeze
cffi==1.6.0
Django==1.11.7
django-cors-headers==2.1.0
django-filter==1.1.0
djangorestframework==3.7.3
greenlet==0.4.9
Markdown==2.6.9
olefile==0.44
Pillow==4.3.0
psycopg2cffi==2.7.7
python-stdnum==1.7
pytz==2017.3
readline==6.2.4.1
six==1.11.0
uWSGI==2.0.15
Log Apache:
[Tue Dec 12 11:15:49.727998 2017] [wsgi:warn] [pid 4975:tid 139854422423424] mod_wsgi: Compiled for Python/2.7.11.
[Tue Dec 12 11:15:49.728151 2017] [wsgi:warn] [pid 4975:tid 139854422423424] mod_wsgi: Runtime using Python/2.7.12.
[Tue Dec 12 11:15:49.729853 2017] [mpm_event:notice] [pid 4975:tid 139854422423424] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
[Tue Dec 12 11:15:49.729893 2017] [core:notice] [pid 4975:tid 139854422423424] AH00094: Command line: '/usr/sbin/apache2'
[Tue Dec 12 11:15:59.608678 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] mod_wsgi (pid=4978): Target WSGI script '/home/user/plataform/project/project/wsgi.py' cannot be loaded as Python module.
[Tue Dec 12 11:15:59.608785 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] mod_wsgi (pid=4978): Exception occurred processing WSGI script '/home/user/plataform/project/project/wsgi.py'.
[Tue Dec 12 11:15:59.608821 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] Traceback (most recent call last):
[Tue Dec 12 11:15:59.608859 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] File "/home/user/plataform/project/project/wsgi.py", line 16, in <module>
[Tue Dec 12 11:15:59.608957 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] application = get_wsgi_application()
[Tue Dec 12 11:15:59.608974 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] File "/home/user/env/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Tue Dec 12 11:15:59.609017 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] django.setup(set_prefix=False)
[Tue Dec 12 11:15:59.609032 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] File "/home/user/env/site-packages/django/__init__.py", line 27, in setup
[Tue Dec 12 11:15:59.609090 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] apps.populate(settings.INSTALLED_APPS)
[Tue Dec 12 11:15:59.609112 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] File "/home/user/env/site-packages/django/apps/registry.py", line 108, in populate
[Tue Dec 12 11:15:59.609256 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] app_config.import_models()
[Tue Dec 12 11:15:59.609277 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] File "/home/user/env/site-packages/django/apps/config.py", line 202, in import_models
[Tue Dec 12 11:15:59.609366 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] self.models_module = import_module(models_module_name)
[Tue Dec 12 11:15:59.609389 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[Tue Dec 12 11:15:59.609451 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] __import__(name)
[Tue Dec 12 11:15:59.609465 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] File "/home/user/env/site-packages/django/contrib/auth/models.py", line 4, in <module>
[Tue Dec 12 11:15:59.609580 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
[Tue Dec 12 11:15:59.609593 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] File "/home/user/env/site-packages/django/contrib/auth/base_user.py", line 52, in <module>
[Tue Dec 12 11:15:59.609671 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] class AbstractBaseUser(models.Model):
[Tue Dec 12 11:15:59.609686 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] File "/home/user/env/site-packages/django/db/models/base.py", line 124, in __new__
[Tue Dec 12 11:15:59.610123 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] new_class.add_to_class('_meta', Options(meta, app_label))
[Tue Dec 12 11:15:59.610139 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] File "/home/user/env/site-packages/django/db/models/base.py", line 325, in add_to_class
[Tue Dec 12 11:15:59.610194 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] value.contribute_to_class(cls, name)
[Tue Dec 12 11:15:59.610216 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] File "/home/user/env/site-packages/django/db/models/options.py", line 214, in contribute_to_class
[Tue Dec 12 11:15:59.610429 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
[Tue Dec 12 11:15:59.610446 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] File "/home/user/env/site-packages/django/db/__init__.py", line 33, in __getattr__
[Tue Dec 12 11:15:59.610507 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] return getattr(connections[DEFAULT_DB_ALIAS], item)
[Tue Dec 12 11:15:59.610521 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] File "/home/user/env/site-packages/django/db/utils.py", line 211, in __getitem__
[Tue Dec 12 11:15:59.610608 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] backend = load_backend(db['ENGINE'])
[Tue Dec 12 11:15:59.610621 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] File "/home/user/env/site-packages/django/db/utils.py", line 115, in load_backend
[Tue Dec 12 11:15:59.610637 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] return import_module('%s.base' % backend_name)
[Tue Dec 12 11:15:59.610646 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[Tue Dec 12 11:15:59.610660 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] __import__(name)
[Tue Dec 12 11:15:59.610668 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] File "/home/user/env/site-packages/django/contrib/gis/db/backends/postgis/base.py", line 2, in <module>
[Tue Dec 12 11:15:59.610706 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] from django.db.backends.postgresql.base import (
[Tue Dec 12 11:15:59.610733 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] File "/home/user/env/site-packages/django/db/backends/postgresql/base.py", line 25, in <module>
[Tue Dec 12 11:15:59.610870 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
[Tue Dec 12 11:15:59.610901 2017] [wsgi:error] [pid 4978:tid 139854259615488] [remote ::1:30039] ImproperlyConfigured: Error loading psycopg2 module: No module named cffi
I made a clean installation of pypy and created a new virtual environment, then changed the conf. of apache for this
<VirtualHost *:80>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
WSGIScriptAlias / /home/user/plataform/project/project/wsgi.py
WSGIDaemonProcess project python-path=/home/user/plataform/project:/home/user/env/site-packages
WSGIProcessGroup project
WSGIPassAuthorization On
<Directory /home/user/plataform/project/project>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /media/ /home/user/plataform/project/media
Alias /static/ /home/user/plataform/project/static
<Directory /home/user/plataform/project/static>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /home/user/plataform/project/media>
Require all granted
</Directory>
</Virtualhost>
and everything worked well
Related
I am trying to host two Django websites on Windows (so no WSGIdaemonprocess). When I did host only one of them it worked perfectly. Now it still works (main path "/" named magazyn). But the second one (path "/awizacje" named awizacje) throws an Internal Server Error. Full error message in Apache logs looks like this:
C:\A\34\s\Modules\_decimal\libmpdec\context.c:57: warning: mpd_setminalloc: ignoring request to set MPD_MINALLOC a second time
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] mod_wsgi (pid=6268): Failed to exec Python script file 'C:/var/www2/awizacje/rootkat/awizacje/wsgi.py'.
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] mod_wsgi (pid=6268): Exception occurred processing WSGI script 'C:/var/www2/awizacje/rootkat/awizacje/wsgi.py'.
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] Traceback (most recent call last):\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] File "C:/var/www2/awizacje/rootkat/awizacje/wsgi.py", line 19, in <module>\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] application = get_wsgi_application()\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] File "C:\\var\\www\\magazyn\\env39\\Lib\\site-packages\\django\\core\\wsgi.py", line 12, in get_wsgi_application\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] django.setup(set_prefix=False)\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] File "C:\\var\\www\\magazyn\\env39\\Lib\\site-packages\\django\\__init__.py", line 19, in setup\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] File "C:\\var\\www\\magazyn\\env39\\Lib\\site-packages\\django\\conf\\__init__.py", line 76, in __getattr__\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] self._setup(name)\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] File "C:\\var\\www\\magazyn\\env39\\Lib\\site-packages\\django\\conf\\__init__.py", line 63, in _setup\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] self._wrapped = Settings(settings_module)\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] File "C:\\var\\www\\magazyn\\env39\\Lib\\site-packages\\django\\conf\\__init__.py", line 142, in __init__\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] mod = importlib.import_module(self.SETTINGS_MODULE)\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] File "C:\\Python39\\lib\\importlib\\__init__.py", line 127, in import_module\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] return _bootstrap._gcd_import(name[level:], package, level)\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] File "<frozen importlib._bootstrap>", line 1030, in _gcd_import\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] File "<frozen importlib._bootstrap>", line 1007, in _find_and_load\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] File "<frozen importlib._bootstrap>", line 1030, in _gcd_import\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] File "<frozen importlib._bootstrap>", line 1007, in _find_and_load\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked\r
[Mon Oct 11 14:57:35.251409 2021] [wsgi:error] [pid 6268:tid 992] [client 192.168.2.54:25532] ModuleNotFoundError: No module named 'awizacje'\r
My httpd.conf looks like this:
WSGIPythonHome "C:/var/www/magazyn/env39"
WSGIPythonPath "C:/var/www/magazyn/venv/Lib/site-packages;C:/var/www/magazyn/rootkat/"
ServerName www.magazyn-stolarz.pl
LoadFile "C:/Python39/python39.dll"
LoadModule wsgi_module "C:/var/www/magazyn/env39/lib/site-packages/mod_wsgi/server/mod_wsgi.cp39-win_amd64.pyd"
WSGIScriptAlias /awizacje "C:/var/www2/awizacje/rootkat/awizacje/wsgi.py"
WSGIScriptAlias / "C:/var/www/magazyn/rootkat/magazyn/wsgi.py"
<Directory "C:/var/www/magazyn/rootkat/magazyn/">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static "C:/var/www/static/"
<Directory "C:/var/www/static/">
Require all granted
</Directory>
<Directory "C:/var/www2/awizacje/rootkat/awizacje/">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /statica "C:/var/www2/static/"
<Directory "C:/var/www2/static/">
Require all granted
</Directory>
My wsgi.py settings in 'awizacje' project:
"""
WSGI config for magazyn 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/3.2/howto/deployment/wsgi/
"""
import os
import sys
import site
from django.core.wsgi import get_wsgi_application
#os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'awizacje.settings')
os.environ["DJANGO_SETTINGS_MODULE"] = "awizacje.settings"
application = get_wsgi_application()
site.addsitedir('C:/var/www2/awizacje/venv/Lib/site-packages')
sys.path.append('C:/var/www2/awizacje')
sys.path.append('C:/var/www2/awizacje/rootkat')
What am I doing wrong? I sadly can't use Linux which would be pretty straightforward.
It looks like what I was missing was appending directories BEFORE get_wsgi_application() command in wsgi.py
"""
WSGI config for magazyn 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/3.2/howto/deployment/wsgi/
"""
import os
import sys
import site
from django.core.wsgi import get_wsgi_application
#os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'awizacje.settings')
os.environ["DJANGO_SETTINGS_MODULE"] = "awizacje.settings"
application = get_wsgi_application()
site.addsitedir('C:/var/www2/awizacje/venv/Lib/site-packages')
sys.path.append('C:/var/www2/awizacje')
sys.path.append('C:/var/www2/awizacje/rootkat')
I am trying to start my first django app with Apache2 (2.4.18).
Unfortunately, I got a bit stuck. This is the error code i get in my log file:
[Wed Mar 11 06:31:32.668937 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] mod_wsgi (pid=14849): Target WSGI script '/home/nigsdtm/srv/portal/mysite/wsgi.py' cannot be loaded as Python module.
[Wed Mar 11 06:31:32.669026 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] mod_wsgi (pid=14849): Exception occurred processing WSGI script '/home/nigsdtm/srv/portal/mysite/wsgi.py'.
[Wed Mar 11 06:31:32.669734 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] Traceback (most recent call last):
[Wed Mar 11 06:31:32.669779 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] File "/home/nigsdtm/srv/portal/mysite/wsgi.py", line 16, in <module>
[Wed Mar 11 06:31:32.669783 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] application = get_wsgi_application()
[Wed Mar 11 06:31:32.669789 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] File "/usr/local/lib/python3.5/dist-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Wed Mar 11 06:31:32.669792 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] django.setup(set_prefix=False)
[Wed Mar 11 06:31:32.669809 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] File "/usr/local/lib/python3.5/dist-packages/django/__init__.py", line 24, in setup
[Wed Mar 11 06:31:32.669812 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] apps.populate(settings.INSTALLED_APPS)
[Wed Mar 11 06:31:32.669817 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] File "/usr/local/lib/python3.5/dist-packages/django/apps/registry.py", line 112, in populate
[Wed Mar 11 06:31:32.669820 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] app_config.import_models()
[Wed Mar 11 06:31:32.669824 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] File "/usr/local/lib/python3.5/dist-packages/django/apps/config.py", line 198, in import_models
[Wed Mar 11 06:31:32.669827 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] self.models_module = import_module(models_module_name)
[Wed Mar 11 06:31:32.669832 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
[Wed Mar 11 06:31:32.669834 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] return _bootstrap._gcd_import(name[level:], package, level)
[Wed Mar 11 06:31:32.669839 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] File "<frozen importlib._bootstrap>", line 986, in _gcd_import
[Wed Mar 11 06:31:32.669843 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] File "<frozen importlib._bootstrap>", line 969, in _find_and_load
[Wed Mar 11 06:31:32.669848 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
[Wed Mar 11 06:31:32.669852 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
[Wed Mar 11 06:31:32.669857 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] File "<frozen importlib._bootstrap_external>", line 665, in exec_module
[Wed Mar 11 06:31:32.669861 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
[Wed Mar 11 06:31:32.669866 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] File "/usr/local/lib/python3.5/dist-packages/polls/models.py", line 14, in <module>
[Wed Mar 11 06:31:32.669869 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] class Choice(models.Model):
[Wed Mar 11 06:31:32.669873 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] File "/usr/local/lib/python3.5/dist-packages/polls/models.py", line 15, in Choice
[Wed Mar 11 06:31:32.669886 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] question = models.ForeignKey(Question)
[Wed Mar 11 06:31:32.669900 2020] [wsgi:error] [pid 14849:tid 140433834096384] [remote 10.150.29.220:33874] TypeError: __init__() missing 1 required positional argument: 'on_delete'
[Wed Mar 11 06:31:47.868251 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] mod_wsgi (pid=15027): Target WSGI script '/home/nigsdtm/srv/portal/mysite/wsgi.py' cannot be loaded as Python module.
[Wed Mar 11 06:31:47.868326 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] mod_wsgi (pid=15027): Exception occurred processing WSGI script '/home/nigsdtm/srv/portal/mysite/wsgi.py'.
[Wed Mar 11 06:31:47.869029 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] Traceback (most recent call last):
[Wed Mar 11 06:31:47.869078 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] File "/home/nigsdtm/srv/portal/mysite/wsgi.py", line 16, in <module>
[Wed Mar 11 06:31:47.869082 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] application = get_wsgi_application()
[Wed Mar 11 06:31:47.869087 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] File "/usr/local/lib/python3.5/dist-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Wed Mar 11 06:31:47.869090 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] django.setup(set_prefix=False)
[Wed Mar 11 06:31:47.869098 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] File "/usr/local/lib/python3.5/dist-packages/django/__init__.py", line 24, in setup
[Wed Mar 11 06:31:47.869101 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] apps.populate(settings.INSTALLED_APPS)
[Wed Mar 11 06:31:47.869105 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] File "/usr/local/lib/python3.5/dist-packages/django/apps/registry.py", line 112, in populate
[Wed Mar 11 06:31:47.869108 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] app_config.import_models()
[Wed Mar 11 06:31:47.869112 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] File "/usr/local/lib/python3.5/dist-packages/django/apps/config.py", line 198, in import_models
[Wed Mar 11 06:31:47.869115 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] self.models_module = import_module(models_module_name)
[Wed Mar 11 06:31:47.869119 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
[Wed Mar 11 06:31:47.869122 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] return _bootstrap._gcd_import(name[level:], package, level)
[Wed Mar 11 06:31:47.869127 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] File "<frozen importlib._bootstrap>", line 986, in _gcd_import
[Wed Mar 11 06:31:47.869132 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] File "<frozen importlib._bootstrap>", line 969, in _find_and_load
[Wed Mar 11 06:31:47.869136 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
[Wed Mar 11 06:31:47.869141 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
[Wed Mar 11 06:31:47.869146 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] File "<frozen importlib._bootstrap_external>", line 665, in exec_module
[Wed Mar 11 06:31:47.869158 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
[Wed Mar 11 06:31:47.869163 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] File "/usr/local/lib/python3.5/dist-packages/polls/models.py", line 14, in <module>
[Wed Mar 11 06:31:47.869166 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] class Choice(models.Model):
[Wed Mar 11 06:31:47.869170 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] File "/usr/local/lib/python3.5/dist-packages/polls/models.py", line 15, in Choice
[Wed Mar 11 06:31:47.869172 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] question = models.ForeignKey(Question)
[Wed Mar 11 06:31:47.869186 2020] [wsgi:error] [pid 15027:tid 140380136130304] [remote 10.150.29.220:57041] TypeError: __init__() missing 1 required positional argument: 'on_delete'
[Wed Mar 11 06:31:48.530646 2020] [wsgi:error] [pid 15027:tid 140380018607872] [remote 10.150.29.220:42180] mod_wsgi (pid=15027): Target WSGI script '/home/nigsdtm/srv/portal/mysite/wsgi.py' cannot be loaded as Python module.
[Wed Mar 11 06:31:48.530748 2020] [wsgi:error] [pid 15027:tid 140380018607872] [remote 10.150.29.220:42180] mod_wsgi (pid=15027): Exception occurred processing WSGI script '/home/nigsdtm/srv/portal/mysite/wsgi.py'.
[Wed Mar 11 06:31:48.530861 2020] [wsgi:error] [pid 15027:tid 140380018607872] [remote 10.150.29.220:42180] Traceback (most recent call last):
[Wed Mar 11 06:31:48.530888 2020] [wsgi:error] [pid 15027:tid 140380018607872] [remote 10.150.29.220:42180] File "/home/nigsdtm/srv/portal/mysite/wsgi.py", line 16, in <module>
[Wed Mar 11 06:31:48.530891 2020] [wsgi:error] [pid 15027:tid 140380018607872] [remote 10.150.29.220:42180] application = get_wsgi_application()
[Wed Mar 11 06:31:48.530897 2020] [wsgi:error] [pid 15027:tid 140380018607872] [remote 10.150.29.220:42180] File "/usr/local/lib/python3.5/dist-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Wed Mar 11 06:31:48.530897 2020] [wsgi:error] [pid 15027:tid 140380018607872] [remote 10.150.29.220:42180] File "/usr/local/lib/python3.5/dist-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Wed Mar 11 06:31:48.530899 2020] [wsgi:error] [pid 15027:tid 140380018607872] [remote 10.150.29.220:42180] django.setup(set_prefix=False)
[Wed Mar 11 06:31:48.530904 2020] [wsgi:error] [pid 15027:tid 140380018607872] [remote 10.150.29.220:42180] File "/usr/local/lib/python3.5/dist-packages/django/__init__.py", line 24, in setup
[Wed Mar 11 06:31:48.530907 2020] [wsgi:error] [pid 15027:tid 140380018607872] [remote 10.150.29.220:42180] apps.populate(settings.INSTALLED_APPS)
[Wed Mar 11 06:31:48.530911 2020] [wsgi:error] [pid 15027:tid 140380018607872] [remote 10.150.29.220:42180] File "/usr/local/lib/python3.5/dist-packages/django/apps/registry.py", line 81, in populate
[Wed Mar 11 06:31:48.530914 2020] [wsgi:error] [pid 15027:tid 140380018607872] [remote 10.150.29.220:42180] raise RuntimeError("populate() isn't reentrant")
[Wed Mar 11 06:31:48.530927 2020] [wsgi:error] [pid 15027:tid 140380018607872] [remote 10.150.29.220:42180] RuntimeError: populate() isn't reentrant
This is my apache2 config file:
Listen 80
<VirtualHost *:80>
ServerAdmin alexandru.bran#nokia.com
ServerName app.gdceur.eecloud.dynamic.nsn-net.net
DocumentRoot /home/nigsdtm/srv
Alias /static /home/nigsdtm/srv/portal/mysite/static
<Directory "/home/nigsdtm/srv/portal/mysite/static">
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/portal_error.log
CustomLog ${APACHE_LOG_DIR}/portal_access.log combined
WSGIDaemonProcess mysite python-home=/home/nigsdtm/srv/portal/ python-path=/home/nigsdtm/srv/portal/venv
WSGIProcessGroup mysite
WSGIScriptAlias / /home/nigsdtm/srv/portal/mysite/wsgi.py
<Directory /home/nigsdtm/srv/portal/mysite>
<Files wsgi.py>
Allow from all
</Files>
</Directory>
</VirtualHost>
This is my wsgi file:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
application = get_wsgi_application()
Project folder name (where manage.py is) is called 'portal'
Folder containing wsgi: 'mysite'
App works if I run server from python environment.
I am running Django 2.1.15 with Python 3.5.2
Could you please give me a hint?
Thanks,
Alexandru
I see this line of error:
TypeError: __init__() missing 1 required positional argument: 'on_delete'
This one I recognized as a missing on_delete statement in a ForeignKey attribute.
According to Django2 changelog:
The on_delete argument for ForeignKey and OneToOneField is now required in models and migrations. Consider squashing migrations so that you have fewer of them to update.
You might have developed your application on Django1 and trying to deploy it with Django2.
You should check that you installed the same dependencies on your production server than on your development machine.
I want to serve my Django applications using Apache2 and the mod_wsgi module. I have setup an Apache virtualhost at /etc/apache2/sites-available/mysite.confand I have made some configuration changes to WSGI at home/username/development/mysite/mysite/wsgi.py However, when I navigate to mydomain.com, I am being presented with the 500 Internal Server Error: The server encountered an internal error or misconfiguration and was unable to complete your request.. I am very new to server development and have never used Apache2 before so I am unsure as to where I have gone wrong in my configuration. Below you will find my virtualhost configuration file as well as my WSGI file. Additionally, I have provided the structure layout of my project directory in case this helps. Any help is greatly appreciated.
directory structure
>> home
>> username
>> development
>> mysite
>> mysite
>> settings.py
>> wsgi.py
>> website
>> static
>> manage.py
>> venv
mysite.conf
<VirtualHost *:80>
ServerName mydomain.com
DocumentRoot /home/username/development/mysite
WSGIScriptAlias / /home/username/development/mysite/mysite/wsgi.py
WSGIDaemonProcess mydomain.com processes=2 threads=15 display-name=%{GROUP} python-home=/home/username/development/venv/lib/python3.5
WSGIProcessGroup mydomain.com
<directory /home/username/development/mysite>
AllowOverride all
Require all granted
Options FollowSymlinks
</directory>
Alias /static/ /home/username/development/mysite/website/static/
<Directory /home/username/development/mysite/website/static>
Require all granted
</Directory>
</VirtualHost>
wsgi.py
import os
import time
import traceback
import signal
import sys
from django.core.wsgi import get_wsgi_application
sys.path.append('/home/username/development/mysite')
# adjust the Python version in the line below as needed
sys.path.append('/home/username/development/venv/lib/python3.5/site-packages')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
try:
application = get_wsgi_application()
except Exception:
# Error loading applications
if 'mod_wsgi' in sys.modules:
traceback.print_exc()
os.kill(os.getpid(), signal.SIGINT)
time.sleep(2.5)
error.log
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/pdo_mysql.so' - /usr/lib/php/20151012/pdo_mysql.so: undefined symbol: mysqlnd_connect in Unknown on line 0
[Mon Aug 05 06:25:02.417656 2019] [wsgi:warn] [pid 11931] mod_wsgi: Compiled for Python/3.5.1+.
[Mon Aug 05 06:25:02.417679 2019] [wsgi:warn] [pid 11931] mod_wsgi: Runtime using Python/3.5.2.
[Mon Aug 05 06:25:02.418568 2019] [mpm_prefork:notice] [pid 11931] AH00163: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/3.5.2 configured -- resuming normal operations
[Mon Aug 05 06:25:02.418590 2019] [core:notice] [pid 11931] AH00094: Command line: '/usr/sbin/apache2'
[Mon Aug 05 10:09:39.950527 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] mod_wsgi (pid=23705): Target WSGI script '/home/username/development/mysite/mysite/wsgi.py' cannot be loaded as Python module.
[Mon Aug 05 10:09:39.950606 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] mod_wsgi (pid=23705): Exception occurred processing WSGI script '/home/username/development/mysite/mysite/wsgi.py'.
[Mon Aug 05 10:09:39.951482 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] Traceback (most recent call last):
[Mon Aug 05 10:09:39.951546 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] File "/home/username/development/mysite/mysite/wsgi.py", line 16, in <module>
[Mon Aug 05 10:09:39.951552 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] application = get_wsgi_application()
[Mon Aug 05 10:09:39.951564 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] File "/home/username/development/venv/lib/python3.5/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Mon Aug 05 10:09:39.951569 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] django.setup(set_prefix=False)
[Mon Aug 05 10:09:39.951577 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] File "/home/username/development/venv/lib/python3.5/site-packages/django/__init__.py", line 19, in setup
[Mon Aug 05 10:09:39.951597 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Mon Aug 05 10:09:39.951607 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] File "/home/username/development/venv/lib/python3.5/site-packages/django/conf/__init__.py", line 79, in __getattr__
[Mon Aug 05 10:09:39.951612 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] self._setup(name)
[Mon Aug 05 10:09:39.951619 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] File "/home/username/development/venv/lib/python3.5/site-packages/django/conf/__init__.py", line 66, in _setup
[Mon Aug 05 10:09:39.951623 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] self._wrapped = Settings(settings_module)
[Mon Aug 05 10:09:39.951630 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] File "/home/username/development/venv/lib/python3.5/site-packages/django/conf/__init__.py", line 157, in __init__
[Mon Aug 05 10:09:39.951634 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] mod = importlib.import_module(self.SETTINGS_MODULE)
[Mon Aug 05 10:09:39.951640 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] File "/home/username/development/venv/lib/python3.5/importlib/__init__.py", line 126, in import_module
[Mon Aug 05 10:09:39.951644 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] return _bootstrap._gcd_import(name[level:], package, level)
[Mon Aug 05 10:09:39.951651 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] File "<frozen importlib._bootstrap>", line 986, in _gcd_import
[Mon Aug 05 10:09:39.951657 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] File "<frozen importlib._bootstrap>", line 969, in _find_and_load
[Mon Aug 05 10:09:39.951664 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
[Mon Aug 05 10:09:39.951671 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
[Mon Aug 05 10:09:39.951678 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] File "<frozen importlib._bootstrap>", line 986, in _gcd_import
[Mon Aug 05 10:09:39.951696 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] File "<frozen importlib._bootstrap>", line 969, in _find_and_load
[Mon Aug 05 10:09:39.951704 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
[Mon Aug 05 10:09:39.951725 2019] [wsgi:error] [pid 23705] [remote 10.100.60.43:0] ImportError: No module named 'mysite'
[Mon Aug 05 10:52:33.048933 2019] [mpm_prefork:notice] [pid 11931] AH00169: caught SIGTERM, shutting down
mysite.conf edit
<VirtualHost *:80>
ServerName mydomain.com
DocumentRoot /home/username/development/mysite
WSGIScriptAlias / /home/username/development/mysite/mysite/wsgi.py
WSGIDaemonProcess mydomain.com python-home=/home/username/development/venv python-path=/home/username/developement/mysite
WSGIProcessGroup mydomain.com
<directory /home/username/development/mysite>
AllowOverride all
Require all granted
Options FollowSymlinks
</directory>
Alias /static/ /home/username/development/mysite/website/static/
<Directory /home/username/development/mysite/website/static>
Require all granted
</Directory>
</VirtualHost>
I'm using Ubuntu 14.04.
I create a django project under /opt/cashpro/python_app/cashsite/trunk/cash
and create a wsgi file cash.wsgi in the same directory
Here is the content of cash.wsgi
import os
import sys
path = '/opt/cashpro/python_app/cashsite/trunk/'
sys.path.insert(0, path)
from cash import settings
import django.core.management
sys.path.insert(1, '/opt/cashpro/python_app/cashsite/trunk/cash/')
django.core.management.setup_environ(settings)
utility = django.core.management.ManagementUtility()
command = utility.fetch_command('runserver')
command.validate()
import django.conf
import django.utils
django.utils.translation.activate(django.conf.settings.LANGUAGE_CODE)
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
and here is what I add to my httpd.conf:
<VirtualHost *:443>
ServerName www.abcd.org
DocumentRoot /var/www/test
SSLEngine on
SSLCipherSuite HIGH:+MEDIUM:!SSLv2:!EXP:!ADH:!aNULL:!eNULL:!NULL
SSLCertificateFile "/opt/certs/www.abcd.org.crt"
SSLCertificateKeyFile "/opt/ssl/www.abcd.key"
SSLCertificateChainFile "/opt/certs/DigiCertCA.crt"
#SSLCertificateChainFile "/opt/ssl/IntermediatesCA3.crt"
BrowserMatch ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
Alias /media-cash/ /opt/cashpro/cashfiles
<Directory /opt/cashpro/cashfiles>
Options MultiViews
AllowOverride None
Require all granted
</Directory>
WSGIPassAuthorization On
WSGIScriptAlias /site
/opt/cashpro/python_app/cashsite/trunk/cash/cash.wsgi
ErrorLog /var/log/apache2/serror.log
CustomLog /var/log/apache2/saccess.log common
</VirtualHost>
The problem is, when I visit https://www.abcd.org/site, it says
Forbidden
You don't have permission to access / on this server.
Apache Error log
[Thu Jul 20 22:24:56.263573 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] mod_wsgi (pid=4448): Target WSGI script
'/opt/cashpro/python_app/cashsite/trunk/cash/cash.wsgi' cannot be loaded as
Python module., referer: https://www.abcd.org
[Thu Jul 20 22:24:56.263816 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] mod_wsgi (pid=4448): Exception occurred
processing WSGI script
'/opt/cashpro/python_app/cashsite/trunk/cash/cash.wsgi'., referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.263978 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] Traceback (most recent call last):, referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264085 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File
"/opt/cashpro/python_app/cashsite/trunk/cash/cash.wsgi", line 11, in
<module>, referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264223 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] command =
utility.fetch_command('runserver'), referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264261 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/core/management/__init__.py", line 261, in fetch_command,
referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264325 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] klass = load_command_class(app_name,
subcommand), referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264360 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/core/management/__init__.py", line 69, in
load_command_class, referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264410 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] module =
import_module('%s.management.commands.%s' % (app_name, name)), referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264452 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/utils/importlib.py", line 35, in import_module, referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264495 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] __import__(name), referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264524 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/core/management/commands/runserver.py", line 8, in <module>,
referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264570 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] from django.core.servers.basehttp import
AdminMediaHandler, run, WSGIServerException, get_internal_wsgi_application,
referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264599 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/core/servers/basehttp.py", line 26, in <module>, referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264637 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] from django.views import static, referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264665 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/views/static.py", line 95, in <module>, referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264700 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] template_translatable =
ugettext_noop(u"Index of %(directory)s"), referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264727 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/utils/translation/__init__.py", line 75, in gettext_noop,
referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264780 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] return _trans.gettext_noop(message),
referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264821 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/utils/translation/__init__.py", line 48, in __getattr__,
referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264852 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] if settings.USE_I18N:, referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264879 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/utils/functional.py", line 184, in inner, referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264912 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] self._setup(), referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264938 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/conf/__init__.py", line 42, in _setup, referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264987 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] self._wrapped = Settings(settings_module),
referer: https://www.abcd.org
[Thu Jul 20 22:24:56.265015 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/conf/__init__.py", line 135, in __init__, referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.265044 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] logging_config_func(self.LOGGING),
referer: https://www.abcd.org
[Thu Jul 20 22:24:56.265071 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/lib/python2.7/logging/config.py",
line 794, in dictConfig, referer: https://www.abcd.org
[Thu Jul 20 22:24:56.265116 2017] [:error] [pid 4448:tid 140570219427584] [
client xxx.xxx.xxx.xxx:3340] dictConfigClass(config).configure(),
referer: https://www.abcd.org
[Thu Jul 20 22:24:56.265151 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/lib/python2.7/logging/config.py",
line 576, in configure, referer: https://www.abcd.org
[Thu Jul 20 22:24:56.265201 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] '%r: %s' % (name, e)), referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.265284 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] ValueError: Unable to configure handler
'default': [Errno 13] Permission denied: '/opt/cash_site.log', referer:
https://www.abcd.org
Another python web app host the same server.But getting error
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName www.xyz.com
ServerAlias xyz.com
DocumentRoot /opt/nadasnapp/html
<Directory /opt/nadasnapp/html/>
Require all granted
AllowOverride All
</Directory>
LogLevel warn
##FOR NADA
Alias /media/ /opt/nadasnapp/python_app/NaDaWebPro/media/
<Directory /opt/nadasnapp/python_app/NaDaWebPro/media/>
Require all granted
AllowOverride All
</Directory>
Alias /static/ /opt/nadasnapp/python_app/NaDaWebPro/static_root/
<Directory /opt/nadasnapp/python_app/NaDaWebPro/static_root/>
Require all granted
AllowOverride All
</Directory>
#FOR NADA
WSGIPassAuthorization On
WSGIScriptAlias / /opt/nadasnapp/python_app/NaDaWebPro/nada/wsgi.py
<Directory /opt/nadasnapp/python_app/NaDaWebPro/nada>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
The error is
[Sun Jul 23 04:23:14.151745 2017] [:error] [pid 4594:tid
139820915422976]
[client xxx.xxx.xxx.xxx:2244] mod_wsgi (pid=4594): Exception occurred
processing WSGI script
'/opt/nadasnapp/python_app/NaDaWebPro/nada/wsgi.py'.
[Sun Jul 23 04:23:14.151993 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] Traceback (most recent call last):
[Sun Jul 23 04:23:14.152065 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] File "/usr/local/lib/python2.7/dist-
packages/django/core/handlers/wsgi.py", line 219, in __call__
[Sun Jul 23 04:23:14.152135 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] self.load_middleware()
[Sun Jul 23 04:23:14.152166 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] File "/usr/local/lib/python2.7/dist-
packages/django/core/handlers/base.py", line 39, in load_middleware
[Sun Jul 23 04:23:14.152203 2017] [:error] [pid 4594:tid 1
39820915422976]
[client xxx.xxx.xxx.xxx:2244] for middleware_path in
settings.MIDDLEWARE_CLASSES:
[Sun Jul 23 04:23:14.152234 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] File "/usr/local/lib/python2.7/dist-
packages/django/utils/functional.py", line 184, in inner
[Sun Jul 23 04:23:14.152319 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] self._setup()
[Sun Jul 23 04:23:14.152357 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] File "/usr/local/lib/python2.7/dist-
packages/django/conf/__init__.py", line 42, in _setup
[Sun Jul 23 04:23:14.152402 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] self._wrapped =
Settings(settings_module)
[Sun Jul 23 04:23:14.152445 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] File "/usr/local/lib/python2.7/dist-
packages/django/conf/__init__.py", line 95, in __init__
[Sun Jul 23 04:23:14.152484 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] raise ImportError("Could not import
settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Sun Jul 23 04:23:14.152540 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] ImportError: Could not import settings
'cash.settings' (Is it on sys.path?): No module named cash.settings
The directory you gave as argument to the Directory directive was /opt/cashpro/cashfiles, it should be /opt/cashpro/python_app/cashsite/trunk/cash/. That is, where the WSGI script file is located.
I could really use some help here. I am in the process of setting up a test deployment of wagtail on a CentOS7 box and it seems as though the wsgi daemon is not getting access to the necessary python modules. I have checked permissions on all of the directories in the virtual environment and made sure that the owner was apache as well as the group owner was apache (recursively). SELinux is also in permissive mode while I'm trying to figure this out. It's a fresh install of wagtail, no modifications have been made after running the start command from wagtail.
My virtual host config file is as follows:
<VirtualHost *:80>
ServerName <server.name>
ServerAdmin <server.admin>
Alias /static /var/www/<virtual.env>/<project.name>/static
<Directory /var/www/<virtual.env>/<project.name>/static>
Require all granted
</Directory>
<Directory /var/www/<virtual.env>/<project.name>/wsgi.py>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess <project> python-path=/var/www/<virtual.env>/<project.name>/<project.name>:/var/www/<virtual.env/lib/python3.4/site-packages
WSGIProcessGroup <project>
WSGIScriptAlias / /var/www/<project.env>/<project.name>/<project.name>/wsgi.py
ErrorLog /var/log/httpd/<project.name>_error.log
CustomLog /var/log/httpd/<project.name>_access.log combined
My project_error.log file contains the following:
[Thu May 04 18:50:35.596691 2017] [:error] [pid 13101] [remote 10.30.112.49:52] mod_wsgi (pid=13101): Exception occurred processing WSGI script '/var/www/<project.name>_env/<project.name>/<project.name>/wsgi.py'.
[Thu May 04 18:50:35.596712 2017] [:error] [pid 13101] [remote 10.30.112.49:52] Traceback (most recent call last):
[Thu May 04 18:50:35.596733 2017] [:error] [pid 13101] [remote 10.30.112.49:52] File "/var/www/<project.name>_env/<project.name>/<project.name>/wsgi.py", line 18, in <module>
[Thu May 04 18:50:35.596785 2017] [:error] [pid 13101] [remote 10.30.112.49:52] application = get_wsgi_application()
[Thu May 04 18:50:35.596797 2017] [:error] [pid 13101] [remote 10.30.112.49:52] File "/var/www/<project.name>_env/lib/python3.4/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Thu May 04 18:50:35.596836 2017] [:error] [pid 13101] [remote 10.30.112.49:52] django.setup(set_prefix=False)
[Thu May 04 18:50:35.596846 2017] [:error] [pid 13101] [remote 10.30.112.49:52] File "/var/www/<project.name>_env/lib/python3.4/site-packages/django/__init__.py", line 27, in setup
[Thu May 04 18:50:35.596887 2017] [:error] [pid 13101] [remote 10.30.112.49:52] apps.populate(settings.INSTALLED_APPS)
[Thu May 04 18:50:35.596898 2017] [:error] [pid 13101] [remote 10.30.112.49:52] File "/var/www/<project.name>_env/lib/python3.4/site-packages/django/apps/registry.py", line 108, in populate
[Thu May 04 18:50:35.597029 2017] [:error] [pid 13101] [remote 10.30.112.49:52] app_config.import_models(all_models)
[Thu May 04 18:50:35.597039 2017] [:error] [pid 13101] [remote 10.30.112.49:52] File "/var/www/<project.name>_env/lib/python3.4/site-packages/django/apps/config.py", line 199, in import_models
[Thu May 04 18:50:35.597118 2017] [:error] [pid 13101] [remote 10.30.112.49:52] self.models_module = import_module(models_module_name)
[Thu May 04 18:50:35.597131 2017] [:error] [pid 13101] [remote 10.30.112.49:52] File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
[Thu May 04 18:50:35.597177 2017] [:error] [pid 13101] [remote 10.30.112.49:52] __import__(name)
[Thu May 04 18:50:35.597187 2017] [:error] [pid 13101] [remote 10.30.112.49:52] File "/var/www/<project.name>_env/lib/python3.4/site-packages/wagtail/wagtailforms/models.py", line 16, in <module>
[Thu May 04 18:50:35.597283 2017] [:error] [pid 13101] [remote 10.30.112.49:52] from wagtail.wagtailadmin.edit_handlers import FieldPanel
[Thu May 04 18:50:35.597292 2017] [:error] [pid 13101] [remote 10.30.112.49:52] File "/var/www/<project.name>_env/lib/python3.4/site-packages/wagtail/wagtailadmin/edit_handlers.py", line 19, in <module>
[Thu May 04 18:50:35.597493 2017] [:error] [pid 13101] [remote 10.30.112.49:52] from wagtail.wagtailadmin import compare, widgets
[Thu May 04 18:50:35.597503 2017] [:error] [pid 13101] [remote 10.30.112.49:52] File "/var/www/<project.name>_env/lib/python3.4/site-packages/wagtail/wagtailadmin/compare.py", line 5, in <module>
[Thu May 04 18:50:35.597660 2017] [:error] [pid 13101] [remote 10.30.112.49:52] from bs4 import BeautifulSoup
[Thu May 04 18:50:35.597673 2017] [:error] [pid 13101] [remote 10.30.112.49:52] File "/var/www/<project.name>_env/lib/python3.4/site-packages/bs4/__init__.py", line 35, in <module>
[Thu May 04 18:50:35.597822 2017] [:error] [pid 13101] [remote 10.30.112.49:52] from .builder import builder_registry, ParserRejectedMarkup
[Thu May 04 18:50:35.597832 2017] [:error] [pid 13101] [remote 10.30.112.49:52] File "/var/www/<project.name>_env/lib/python3.4/site-packages/bs4/builder/__init__.py", line 7, in <module>
[Thu May 04 18:50:35.597933 2017] [:error] [pid 13101] [remote 10.30.112.49:52] from bs4.element import (
[Thu May 04 18:50:35.597943 2017] [:error] [pid 13101] [remote 10.30.112.49:52] File "/var/www/<project.name>_env/lib/python3.4/site-packages/bs4/element.py", line 10, in <module>
[Thu May 04 18:50:35.598337 2017] [:error] [pid 13101] [remote 10.30.112.49:52] from bs4.dammit import EntitySubstitution
[Thu May 04 18:50:35.598347 2017] [:error] [pid 13101] [remote 10.30.112.49:52] File "/var/www/<project.name>_env/lib/python3.4/site-packages/bs4/dammit.py", line 14, in <module>
[Thu May 04 18:50:35.598548 2017] [:error] [pid 13101] [remote 10.30.112.49:52] from html.entities import codepoint2name
[Thu May 04 18:50:35.598565 2017] [:error] [pid 13101] [remote 10.30.112.49:52] ImportError: No module named html.entities
Huge thanks in advance.
Two things I noticed. <Directory /var/www/<virtual.env>/<project.name>/wsgi.py> should point to the directory <Directory /var/www/<virtual.env>/<project.name>/, not the file itself. Also, mod_wsgi needs to be compiled against the same version of Python you developed against, as #gasman mentioned.
If you want to upgrade to Python 3.5 and install mod_wsgi from the IUS repository:
sudo yum install https://centos7.iuscommunity.org/ius-release.rpm
sudo yum install python35u python35u-pip python35u-devel python35u-mod_wsgi
Good luck!