Django mod_wsgi Apache error 403 Forbidden on Ubuntu 22.04
NickName:Deepak Play Ask DateTime:2022-06-05T14:04:44

Django mod_wsgi Apache error 403 Forbidden on Ubuntu 22.04

Django mod_wsgi on Apache application works fine in Ubuntu 20.04 and previous versions with the configuration mentioned below, but when I do the same configuration in Ubuntu 22.04 it gets 403 Forbidden error. and Permission denied: mod_wsgi in the error log.

I tried changing permission on all files it's doesn't work,

Apache config:

<VirtualHost *:80>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <Directory /home/ubuntu/mydjango/mydjango>
                <Files wsgi.py>
                        Require all granted
                </Files>
        </Directory>

        alias /static /home/ubuntu/mydjango/static
        <Directory /home/ubuntu/mydjango/static>
                Require all granted
        </Directory>

        WSGIDaemonProcess myapp python-home=/home/ubuntu/mydjango/venv python-path=/home/ubuntu/mydjango
        WSGIProcessGroup myapp
        WSGIScriptAlias / /home/ubuntu/mydjango/mydjango/wsgi.py
</VirtualHost>

Apache Error Log:

Current thread 0x00007fb606719780 (most recent call first):
  <no Python frame>
[Sun Jun 05 05:59:07.594727 2022] [wsgi:warn] [pid 37044:tid 140419768883072] (13)Permission denied: mod_wsgi (pid=37044): Unable to stat Python home /home/ubuntu/mydjango/venv. Python interpreter may not be able to be initialized correctly. Verify the supplied path and access permissions for whole of the path.
Python path configuration:
  PYTHONHOME = '/home/ubuntu/mydjango/venv'
  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/ubuntu/mydjango/venv'
  sys.base_exec_prefix = '/home/ubuntu/mydjango/venv'
  sys.platlibdir = 'lib'
  sys.executable = '/usr/bin/python3'
  sys.prefix = '/home/ubuntu/mydjango/venv'
  sys.exec_prefix = '/home/ubuntu/mydjango/venv'
  sys.path = [
    '/home/ubuntu/mydjango/venv/lib/python310.zip',
    '/home/ubuntu/mydjango/venv/lib/python3.10',
    '/home/ubuntu/mydjango/venv/lib/python3.10/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'

Copyright Notice:Content Author:「Deepak Play」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/72505153/django-mod-wsgi-apache-error-403-forbidden-on-ubuntu-22-04

More about “Django mod_wsgi Apache error 403 Forbidden on Ubuntu 22.04” related questions

Django mod_wsgi Apache error 403 Forbidden on Ubuntu 22.04

Django mod_wsgi on Apache application works fine in Ubuntu 20.04 and previous versions with the configuration mentioned below, but when I do the same configuration in Ubuntu 22.04 it gets 403 Forbi...

Show Detail

Apache mod_wsgi throwing error "403 Forbidden" when deploying a Django project

I have been trying to deploy a Django site using mod_wsgi on a CentOS server recently, but so far when I try to access the django site through my laptop, the web page has only been displaying error...

Show Detail

django and apache: get traceback of 403 Forbidden

I am developing a web app with Django and apache. I can access the homepage but when I log in I get 403 Forbidden. Where can I get a traceback of the error so I can solve the problem? I am develop...

Show Detail

Django with mod_wsgi returns 403 error

I am trying to use Django with Apache (and mod_wsgi). With the default Django webserver everything was going well, but now I get 403 (access forbidden) error when trying to load the page. I searched

Show Detail

403 Forbidden error with Django and mod_wsgi

I created Django project in home directory so it is in home directory. Setup Django Verison : 1.5.1 Python Version : 2.7.5 mod_wsgi Version: 3.4 Home Directory : /home/aettool Contents of /home/

Show Detail

403 Error - Apache VirtualHost - Ubuntu 22.04

i recently install ubuntu 22.04 and try to use LAMP on it. but i have problem with VirtualHost. i want use virtualhosts with a local domain like: test.local i added this domain to /etc/hosts and ad...

Show Detail

Django with Apache and mod_wsgi getting a 403(Forbidden)

I am trying to get a Django app running on Apache with mod_wsgi. I got a 403(Forbidden) for both any file in /static and /(the Django app). The apache user has permission to the wsgi.py and can list /

Show Detail

Django Apache setup - forbidden Error 403

Since it did not work on the first time, I created a fresh new venv for my django project. my folder structure looks like this: btw I used the Django/Apache Setup guide from digitalOcean (https://www.

Show Detail

Django server error 403 forbidden nginx/1.10.3 (ubuntu)

I have some media content in ubuntu server. I can upload files. but when I try to load files it shows 403 forbidden nginx/1.10.3 (ubuntu).In file permission, it displays rw--------. How can I retr...

Show Detail

403 error on Apache Server with Django application

I've been searching throughout this site for a solution but haven't been able to find one. I have a CentOS 6.4 server with Apache 2.2.15, Django 1.6 and mod_wsgi 3.2. I am using Apache to display

Show Detail