Remove 'mod_wsgi.server' from installed apps in the Django settings file. It is only relevant when using mod_wsgi-express, not when hosting with mod_wsgi integrated into Apache manually.
> On 8 Nov 2019, at 1:34 am, Patrick Carra <[email protected]> wrote: > > Hello I am attempting to configure a django application using mod_wsgi and > apache2. My current installation of mod_wsgi and apache is: > > [root@6e5907c50b36 modules]# strings mod_wsgi.so | grep -w -A 2 "wsgi_init" > wsgi_init > 4.6.5 > mod_wsgi/%s > > [root@6e5907c50b36 modules]# httpd -version > Server version: Apache/2.4.6 (CentOS) > Server built: Aug 8 2019 11:41:18 > > My httpd.conf configuration for wsgi is: > # Supplemental configuration > # > # Load config files in the "/etc/httpd/conf.d" directory, if any. > LoadModule wsgi_module modules/mod_wsgi.so > #IncludeOptional conf.d/*.conf > # > WSGIScriptAlias / /home/db_user/ciopsdb/ciopsdb/wsgi.py > WSGIPythonHome /home/db_user/ciopsdb/venv > WSGIPythonPath /home/db_user/ciopsdb > > > <Directory /home/db_user/ciopsdb/ciopsdb> > <Files wsgi.py> > Require all granted > </Files> > </Directory> > > For django my version and configuration I am using a virtual environment. I > previously had mod_wsgi 4.6.8 installed via pip but I was getting an error > that wsgi could not accept the request.GET method I was passing to use a > django-filter. While I was using the django development server this had > worked fine so I assumed that there was a problem with the > configuration/version of mod_wsgi inside my virtual python environment. I > removed the mod_wsgi package from Python and manually installed mod_wsgi > 4.6.5 into apache itself. Django configs and versions below: > > (venv) [db_user@6e5907c50b36 ciopsdb]$ pip freeze > Django==2.2.4 > django-filter==2.2.0 > django-tables2==2.1.1 > djangorestframework==3.10.3 > psycopg2==2.8.4 > psycopg2-binary==2.8.4 > pytz==2019.3 > sqlparse==0.3.0 > > > (venv) [db_user@6e5907c50b36 ciopsdb]$ cat wsgi.py > """ > WSGI config for ciopsdb 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/2.2/howto/deployment/wsgi/ > """ > > > import os > > > from django.core.wsgi import get_wsgi_application > > > os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ciopsdb.settings') > > > application = get_wsgi_application() > > > With this current configuration the error I get from the > /etc/httpd/logs/error_log is: > > [Thu Nov 07 13:54:30.304640 2019] [wsgi:info] [pid 64753] mod_wsgi > (pid=64753): Create interpreter '*****|'. > [Thu Nov 07 13:54:30.318061 2019] [wsgi:info] [pid 64753] mod_wsgi > (pid=64753): Adding '/home/db_user/ciopsdb' to path. > [Thu Nov 07 13:54:30.318600 2019] [wsgi:info] [pid 64753] [client > 142.136.2.11:58968] mod_wsgi (pid=64753, process='', application='****'|'): > Loading Python script file '/home/db_user/ciopsdb/ciopsdb/wsgi.py'., referer: > http://***** > [Thu Nov 07 13:54:30.551588 2019] [wsgi:error] [pid 64753] [client > 142.136.2.11:58968] mod_wsgi (pid=64753): Failed to exec Python script file > '/home/db_user/ciopsdb/ciopsdb/wsgi.py'., referer: http://***** > [Thu Nov 07 13:54:30.551638 2019] [wsgi:error] [pid 64753] [client > 142.136.2.11:58968] mod_wsgi (pid=64753): Exception occurred processing WSGI > script '/home/db_user/ciopsdb/ciopsdb/wsgi.py'., referer: http://***** > [Thu Nov 07 13:54:30.552417 2019] [wsgi:error] [pid 64753] [client > 142.136.2.11:58968] Traceback (most recent call last):, referer: http://***** > [Thu Nov 07 13:54:30.552478 2019] [wsgi:error] [pid 64753] [client > 142.136.2.11:58968] File "/home/db_user/ciopsdb/ciopsdb/wsgi.py", line 16, > in <module>, referer: http://***** > [Thu Nov 07 13:54:30.552485 2019] [wsgi:error] [pid 64753] [client > 142.136.2.11:58968] application = get_wsgi_application(), referer: > http://***** > [Thu Nov 07 13:54:30.552492 2019] [wsgi:error] [pid 64753] [client > 142.136.2.11:58968] File > "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/wsgi.py", > line 12, in get_wsgi_application, http://***** > [Thu Nov 07 13:54:30.552496 2019] [wsgi:error] [pid 64753] [client > 142.136.2.11:58968] django.setup(set_prefix=False), referer: http://***** > [Thu Nov 07 13:54:30.552501 2019] [wsgi:error] [pid 64753] [client > 142.136.2.11:58968] File > "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/__init__.py", > line 24, in setup, referer: http://***** > [Thu Nov 07 13:54:30.552511 2019] [wsgi:error] [pid 64753] [client > 142.136.2.11:58968] apps.populate(settings.INSTALLED_APPS), referer: > http://***** > [Thu Nov 07 13:54:30.552517 2019] [wsgi:error] [pid 64753] [client > 142.136.2.11:58968] File > "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/apps/registry.py", > line 91, in populate, referer: http://***** > [Thu Nov 07 13:54:30.552521 2019] [wsgi:error] [pid 64753] [client > 142.136.2.11:58968] app_config = AppConfig.create(entry), referer: > http://***** > [Thu Nov 07 13:54:30.552526 2019] [wsgi:error] [pid 64753] [client > 142.136.2.11:58968] File > "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/apps/config.py", > line 136, in create, referer: http://***** > [Thu Nov 07 13:54:30.552529 2019] [wsgi:error] [pid 64753] [client > 142.136.2.11:58968] import_module(entry), referer: http://***** > [Thu Nov 07 13:54:30.552534 2019] [wsgi:error] [pid 64753] [client > 142.136.2.11:58968] File "/usr/lib64/python3.6/importlib/__init__.py", line > 126, in import_module, referer: http://***** > [Thu Nov 07 13:54:30.552538 2019] [wsgi:error] [pid 64753] [client > 142.136.2.11:58968] return _bootstrap._gcd_import(name[level:], package, > level), referer: http://***** > [Thu Nov 07 13:54:30.552543 2019] [wsgi:error] [pid 64753] [client > 142.136.2.11:58968] File "<frozen importlib._bootstrap>", line 994, in > _gcd_import, referer: http://***** > [Thu Nov 07 13:54:30.552549 2019] [wsgi:error] [pid 64753] [client > 142.136.2.11:58968] File "<frozen importlib._bootstrap>", line 971, in > _find_and_load, referer: http://***** > [Thu Nov 07 13:54:30.552554 2019] [wsgi:error] [pid 64753] [client > 142.136.2.11:58968] File "<frozen importlib._bootstrap>", line 950, in > _find_and_load_unlocked, referer: http://***** > [Thu Nov 07 13:54:30.552569 2019] [wsgi:error] [pid 64753] [client > 142.136.2.11:58968] ModuleNotFoundError: No module named 'mod_wsgi.server'; > 'mod_wsgi' is not a package, referer: http://***** > > In my browser I get this message: > 500 Internal Server Error > > The server encountered an internal error or misconfiguration and was unable > to complete your request. > > Please contact the server administrator at root@localhost to inform them of > the time this error occurred, and the actions you performed just before this > error. > > More information about this error may be available in the server error log. > > > I am new to linux/apache/mod_wsgi/ but have a little experience with Python. > Any help and suggestions are appreciated as I have looked at many forum posts > and documentation to try to figure this out but have exhausted my current > understanding of these things. Thank you in advance! > > -- > You received this message because you are subscribed to the Google Groups > "modwsgi" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/modwsgi/31aaf341-ace8-4ac0-8a29-344e9b8deabe%40googlegroups.com > > <https://groups.google.com/d/msgid/modwsgi/31aaf341-ace8-4ac0-8a29-344e9b8deabe%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/DC38D970-205C-4043-8214-26A82A741BD3%40gmail.com.
