Ошибка 403 с Apache 2, запущенным на Linode Ubuntu 21.10 в Django

Я следую за "Учебником Python Django: Развертывание приложения (вариант #1) - развертывание на Linux-сервере" Корефа Шафера.

После того, как я активировал свой сервер Apache 2 и попытался получить доступ к своему приложению Django, страница возвращает ошибку 403. Проверив журнал ошибок, я обнаружил следующее:

Current thread 0x00007f57a341f780 (most recent call first):
<no Python frame>
[Sat Nov 06 18:29:53.698451 2021] [wsgi:warn] [pid 24290:tid 140014377891712] (13)Permission denied: mod_wsgi (pid=24290): Unable to stat Python home /home/vavao/website/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/vavao/website/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/vavao/website/venv'
  sys.base_exec_prefix = '/home/vavao/website/venv'
  sys.platlibdir = 'lib'
  sys.executable = '/usr/bin/python3'
  sys.prefix = '/home/vavao/website/venv'
  sys.exec_prefix = '/home/vavao/website/venv'
  sys.path = [
    '/home/vavao/website/venv/lib/python39.zip',
    '/home/vavao/website/venv/lib/python3.9',
    '/home/vavao/website/venv/lib/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'

Current thread 0x00007f57a341f780 (most recent call first):
<no Python frame>

А вот мой файл website.conf

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # 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 www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    # 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
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf

    Alias /static /home/vavao/website/static
    <Directory /home/vavao/website/static>
        Require all granted
    </Directory>

    <Directory /home/vavao/website/website>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    WSGIScriptAlias / /home/vavao/website/website/wsgi.py
    WSGIDaemonProcess django_app python-path=/home/vavao/website python-home=/home/vavao/website/venv
    WSGIProcessGroup django_app
</VirtualHost>

Самое непонятное, что я не получаю другого ответа от браузера, когда я устанавливаю DEBUG = True. Я получаю ту же ошибку 403.

Я нашел следующую проблему на Github: https://github.com/pyinstaller/pyinstaller/issues/5438

Но удаление пакетов не было решением, у меня эти пакеты не были установлены в первую очередь.

Как я могу решить эту проблему?

sudo chmod 711 /home/vavao исправил проблему.

Вернуться на верх