gpt4 book ai didi

python - 在 Django 中的 Linode Ubuntu 21.10 上运行的 Apache 2 出现 403 错误

转载 作者:行者123 更新时间:2023-12-04 19:27:17 26 4
gpt4 key购买 nike

我正在关注 Coref Shafer 的“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解决了这个问题。

关于python - 在 Django 中的 Linode Ubuntu 21.10 上运行的 Apache 2 出现 403 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69866841/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com