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

4nkexdtk  于 2022-12-04  发布在  Apache
关注(0)|答案(2)|浏览(734)

我以前上传过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'

当i键入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服务器上尝试这个项目时,它工作得非常好,否则当我改变以下命令时:一个月一个月一个月一个月

我的问题是,我做错了什么,该如何改正

请让我知道,如果有更多的信息需要帮助解决它

rbpvctlc

rbpvctlc1#

类型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>
bd1hkmkf

bd1hkmkf2#

你好,我很肯定你遇到了同样的问题,因为我没有按照科里Schafer的Django教程在linux服务器上部署Django.
问题是Django项目文件夹的权限设置,Corey在他的视频中没有提到,但如果你运行:

sudo chmod -R 775 ~/django_project/

这将解决该问题。
贷方:
mod_wsgi - Permission denied - Unable to start Python home

相关问题