Запуск Django приложения Apach2: 403 Запрещенная ошибка. Отказано в разрешении: mod_wsgi
Я пытаюсь развернуть свое приложение Django с моим каплетом Digital Ocean. На YouTube был очень полезный учебник, которому я следовал; когда он настроил параметры в Apache2, а затем обновился, он увидел свое приложение Django, тогда как когда я делаю то же самое, я получаю следующую ошибку:
Forbidden
You don't have permission to access this resource.
Apache/2.4.46 (Ubuntu) Server at 159.223.6.157 Port 80
Здесь вы видите настройку моего файла /etc/apache2/sites-available/hbm_project.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/hbm/hbm_project/static
<Directory /home/hbm/hbm_project/static>
Require all granted
</Directory>
<Directory /home/hbm/hbm_project/hbm_project>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIScriptAlias / /home/hbm/hbm_project/hbm_project/wsgi.py
WSGIDaemonProcess hbm_app python-home=/home/hbm/hbm_project/venv python-path=/home/hbm/hbm_project python-ho>
WSGIProcessGroup hbm_app
Когда я смотрю в журнал ошибок Apache2, я вижу следующую ошибку:
[Thu Oct 21 07:07:57.606866 2021] [wsgi:warn] [pid 35891:tid 139970948001088] (13)Permission denied: mod_wsgi (pid=35891): Unable to stat Python home /home/hbm/hbm_project/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/hbm/hbm_project/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/hbm/hbm_project/venv'
sys.base_exec_prefix = '/home/hbm/hbm_project/venv'
sys.platlibdir = 'lib'
sys.executable = '/usr/bin/python3'
sys.prefix = '/home/hbm/hbm_project/venv'
sys.exec_prefix = '/home/hbm/hbm_project/venv'
sys.path = [
'/home/hbm/hbm_project/venv/lib/python39.zip',
'/home/hbm/hbm_project/venv/lib/python3.9',
'/home/hbm/hbm_project/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 0x00007f4d86a26d40 (most recent call first):
<no Python frame>
В интернете есть несколько сопоставимых ошибок, но ни одна из вещей, которые работают для других людей, похоже, не работает для меня. Надеюсь, кто-нибудь сможет мне помочь.
Спасибо!
Попробовать chown -r $USER:$USER /home/hbm/hbm_project