> On 14 Feb 2025, at 3:29 am, [email protected] <[email protected]> wrote: > > Thanks Graham for the prompt response. Here is what I discovered based on > your questions. > > Version Info: > mod_wsgi/4.7.1 > Python/3.9.21 (latest revision) > What would be the correct mod_wsgi version for python 3.9? I couldn't find > this in the documentation anywere for mod_wsgi?
Ideally you would use the most up to date Python version available. You can learn more about Python and what versions are available at: * https://www.python.org/ You appear to be using an old OS distro since they have a quite old version of Python if that is the system supplied Python installation. You are also on an old version of mod_wsgi as well. The latest version is 5.0.2. Is there a reason you are using that specific Linux distro since it appears to be quite old. > (env) [pcarra@ip-10-42-42-120 portal]$ ls -lasd /home/django > 0 drwxr-xr-x. 5 django django 185 Feb 13 14:03 /home/django > > For directory permissions I have changed everything under /home/django to be > owned by django:django and then ran chmod o+rx on /home/django (I had been > using root to create somethings) > > > > > > On Wednesday, February 12, 2025 at 3:00:08 PM UTC-6 Graham Dumpleton wrote: >> Are you sure the system mod_wsgi package you are using is compiled for same >> Python version as the Python virtual environment you are using? >> >> This is usually the culprit for this issue. >> >> Also what are the file system permissions on /home/django >> >> ls -lasd /home/django >> >> Some Linux systems will make home directories non readable to other users, >> which means Apache can't read anything under it, which can result in this >> error. >> >> Would need to do: >> >> chmod o+rx /home/django >> >> for the home directory. >> >> Also, if you have set up stuff under that directory as root, you can have >> similar issues with directories/files under the home directory because umask >> for root is usually such that doesn't allow access to others. >> >> So check directory/file permissions on home directory and project files. >> >> Also ensure that Python is upgraded to latest patch revision at least. >> >> My memory is bad, but on some Linux distros early Python 3.9 patch revisions >> broke ability to be embedded in other systems, with an error like this. >> Problem didn't occur with normal upstream Python and only that shipped by >> the distro. I thought it was Ubuntu though, so may not be relevant. >> >> Graham >> >> >>> On 13 Feb 2025, at 7:42 am, [email protected] <> <[email protected] <>> >>> wrote: >>> >> >>> Hello all I have been following the documentation to install mod_wsgi and >>> configure it for my django Application but I am getting errors when I start >>> httpd. Any help is appreciated.... I've been hammering away at this most >>> of the day unfortunately. >>> >>> Documentation: >>> https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/modwsgi/ >>> https://modwsgi.readthedocs.io/en/develop/user-guides/quick-installation-guide.html >>> >>> httpd.conf: >>> LoadModule wsgi_module modules/mod_wsgi.so <http://mod_wsgi.so/> >>> WSGIScriptAlias / /home/django/portal/sec_web/sec_web/wsgi.py >>> WSGIPythonHome /home/django/portal/env >>> WSGIPythonPath /home/django/portal/sec_web >>> >>> <Directory /home/django/portal/sec_web/sec_web> >>> <Files wsgi.py> >>> Require all granted >>> </Files> >>> </Directory> >>> >>> Directory structure (Portal is just a directory for organization my project >>> is sec_web): >>> portal >>> ├── env >>> │ ├── bin >>> │ │ ├── activate >>> │ │ ├── activate.csh >>> │ │ ├── activate.fish >>> │ │ ├── Activate.ps1 >>> │ │ ├── mod_wsgi-express >>> │ │ ├── pip >>> │ │ ├── pip3 >>> │ │ ├── pip3.9 >>> │ │ ├── python -> python3 >>> │ │ ├── python3 -> /bin/python3 >>> │ │ └── python3.9 -> python3 >>> │ ├── include >>> │ ├── lib >>> │ │ └── python3.9 >>> │ ├── lib64 -> lib >>> │ └── pyvenv.cfg >>> └── sec_web >>> ├── api >>> │ ├── admin.py >>> │ ├── apps.py >>> │ ├── __init__.py >>> │ ├── migrations >>> │ ├── models.py >>> │ ├── __pycache__ >>> │ ├── serializers.py >>> │ ├── tests.py >>> │ ├── urls.py >>> │ └── views.py >>> ├── db.sqlite3 >>> ├── endpoint >>> │ ├── admin.py >>> │ ├── apps.py >>> │ ├── __init__.py >>> │ ├── migrations >>> │ ├── models.py >>> │ ├── __pycache__ >>> │ ├── tests.py >>> │ ├── urls.py >>> │ └── views.py >>> ├── logfile.log >>> ├── logfile.log.bak >>> ├── manage.py >>> ├── requirements.txt >>> ├── sec_web >>> │ ├── asgi.py >>> │ ├── __init__.py >>> │ ├── migrations >>> │ ├── __pycache__ >>> │ ├── settings.py >>> │ ├── urls.py >>> │ ├── utils.py >>> │ └── wsgi.py >>> └── urls.py >>> >>> /var/log/httpd/error_log: >>> Fatal Python error: init_fs_encoding: failed to get the Python codec of the >>> filesystem encoding >>> Python runtime state: core initialized >>> ModuleNotFoundError: No module named 'encodings' >>> >>> Current thread 0x00007fc56a8de540 (most recent call first): >>> <no Python frame> >>> Python path configuration: >>> PYTHONHOME = '/home/django/portal/env' >>> PYTHONPATH = (not set) >>> program name = 'python3' >>> isolated = 0 >>> environment = 1 >>> user site = 1 >>> import site = 1 >>> sys._base_executable = '/usr/bin/python3' >>> sys.base_prefix = '/home/django/portal/env' >>> sys.base_exec_prefix = '/home/django/portal/env' >>> sys.platlibdir = 'lib64' >>> sys.executable = '/usr/bin/python3' >>> sys.prefix = '/home/django/portal/env' >>> sys.exec_prefix = '/home/django/portal/env' >>> sys.path = [ >>> '/home/django/portal/env/lib64/python39.zip', >>> '/home/django/portal/env/lib64/python3.9', >>> '/home/django/portal/env/lib64/python3.9/lib-dynload', >>> ] >>> Fatal Python error: init_fs_encoding: failed to get the Python codec of the >>> filesystem encoding >>> Python runtime state: core initialized >>> ModuleNotFoundError: No module named 'encodings' >>> /var/log/httpd/error_log >>> >>> >>> >> >>> -- >>> 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 visit >>> https://groups.google.com/d/msgid/modwsgi/1b7e6f7e-daae-4ff6-849e-529ca0055355n%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/modwsgi/1b7e6f7e-daae-4ff6-849e-529ca0055355n%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] > <mailto:[email protected]>. > To view this discussion visit > https://groups.google.com/d/msgid/modwsgi/3bf7d2d2-d77a-4d10-abb9-760f9f443d68n%40googlegroups.com > > <https://groups.google.com/d/msgid/modwsgi/3bf7d2d2-d77a-4d10-abb9-760f9f443d68n%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 visit https://groups.google.com/d/msgid/modwsgi/4C3B247E-1433-42DF-B14B-303FF47AA4AF%40gmail.com.
