我正试图部署我的Django应用程序与我的数字海洋液滴。我在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 $USER:$USER /home/hbm/hbm_project