Apache/2.4.46 (Ubuntu) 服务器端口 80 错误

问题描述 投票:0回答:3

我之前上传了 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 8000
sudo ufw allow http/tcp
sudo service apache2 restart

我的问题是我做错了什么以及如何解决它?

如果需要更多信息来帮助修复它,请告诉我

apache linode
3个回答
0
投票

类型

cd /etc/apache2/sites-available/

sudo cp 000-default.conf Portfolio.conf
并添加

    ServerName server_domain_name_or_IP
    <Directory /var/www/html/>
        AllowOverride All
    </Directory>

0
投票

嗨,我很确定您遇到了与我在遵循 Corey Schafer 的关于在 Linux 服务器上部署 django 的 Django 教程时遇到的相同问题。

问题是 Django 项目文件夹的权限设置,Corey 在他的视频中没有提到,但如果你运行:

sudo chmod -R 775 ~/django_project/

这将解决问题。

归功于:

mod_wsgi - 权限被拒绝 - 无法启动 Python 主目录


0
投票

我的 apache 服务器上有两个站点。一个工作没有问题。第二个有效,但前提是我输入https://webpage.com。当我只输入webpage.com 时,它不起作用。在此之前它正在工作。也许更新后出现了问题。这对我来说已经足够了:

a2ensite yourconfig.conf
service apache2 reload
© www.soinside.com 2019 - 2024. All rights reserved.