【发布时间】:2021-10-11 18:02:45
【问题描述】:
我之前上传了 2 个 django 项目,并且在 Linode 服务器上运行良好,但现在由于某种原因,我收到了 403 端口 80 错误的错误。我已经逐字重温了一个教程并修改了好几次,我不知道为什么我总是收到这个错误:
Error for 403 Forbidden You don't have permission to access this resource. Apache/2.4.46 (Ubuntu) Server at Port 80
这是配置文件:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /static /home/ahesham/Portfolio/static
<Directory /home/ahesham/Portfolio/static>
Require all granted
</Directory>
Alias /media /home/ahesham/Portfolio/media
<Directory /home/ahesham/Portfolio/media>
Require all granted
</Directory>
<Directory /home/ahesham/Portfolio/Portfolio>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIScriptAlias / /home/ahesham/Portfolio/Portfolio/wsgi.py
WSGIDaemonProcess Portfolio python-path=/home/ahesham/Portfolio python-home=/home/ahesham/Portfolio/venv
WSGIProcessGroup Portfolio
</VirtualHost>
在错误日志中
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'
当我输入 ls -la
total 36
drwxr-x--- 5 ahesham ahesham 4096 Aug 6 23:08 .
drwxr-xr-x 3 root root 4096 Aug 5 02:30 ..
-rw------- 1 ahesham ahesham 2115 Aug 7 02:20 .bash_history
-rw-r--r-- 1 ahesham ahesham 220 Aug 5 02:30 .bash_logout
-rw-r--r-- 1 ahesham ahesham 3771 Aug 5 02:30 .bashrc
drwx------ 3 ahesham ahesham 4096 Aug 6 12:53 .cache
drwxrwxr-x 10 ahesham www-data 4096 Aug 6 20:15 Portfolio
-rw-r--r-- 1 ahesham ahesham 807 Aug 5 02:30 .profile
drwx------ 2 ahesham ahesham 4096 Aug 5 02:41 .ssh
-rw-r--r-- 1 ahesham ahesham 0 Aug 5 02:42 .sudo_as_admin_successful
当我在 8000 服务器上尝试该项目时,当我更改以下命令时,它运行得非常好:sudo ufw delete allow 8000sudo ufw allow http/tcpsudo service apache2 restart
我的问题是我做错了什么以及如何解决?
如果需要更多信息来帮助修复它,请告诉我
【问题讨论】:
-
请查看 apache 日志并告诉我们它给出的反馈。 /var/log/apache2/error.log
-
这个问题可能更适合unix.stackexchange.com 或serverfault.com。
-
@JordanCasey 我添加了来自 error.log 的错误