簡體   English   中英

在 Fedora 上部署 Django 時,Apache 2.4 出現錯誤“禁止您無權訪問此服務器上的 /static/”

[英]Apache 2.4 giving error "Forbidden You don't have permission to access /static/ on this server" while deploying Django on Fedora

我是 django 的新手,在 apache 上部署 django 時遇到了這個禁止的錯誤。 我已經嘗試了谷歌上幾乎所有可用的解決方案,但仍然沒有解決這個問題。

目前我正在使用:

  • Python3.6
  • 阿帕奇 2.4
  • 軟呢帽 28

我也嘗試將我的項目移動到 /var/www 但這對我也不起作用。

這是我的 httpd.conf 文件的樣子:

<VirtualHost *:80>
ServerName rohit.com
DocumentRoot /home/rohit/django_ionic/
ServerAdmin root@localhost


Alias /static /home/rohit/django_ionic/drfx/static
<Directory "/home/rohit/django_ionic/drfx/static">
Options Indexes FollowSymLinks
Allow from all
Require all granted
</Directory>

<Directory /home/rohit/django_ionic/drfx/drfx>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>

WSGIDaemonProcess mysite1 python-path=/home/rohit/django_ionic/drfx:/usr/lib/python3.6/site-packages
WSGIProcessGroup mysite1
WSGIScriptAlias / /home/rohit/django_ionic/drfx/drfx/wsgi.py
WSGIApplicationGroup %{GLOBAL}

<Directory /home/rohit/django_ionic/drfx/drfx/>
<Files wsgi.py>
Allow from all
Require all granted
</Files>
</Directory>
</VirtualHost>

我還為我的 django 文件夾授予了 chown 權限。 還有一個問題是我的用戶和組是 apache,我已經看到很多使用用戶和組作為 www-data:www-data 的解決方案。 這真的有什么不同嗎,因為我已經通過使用 apache:apache 授予了權限。

您使用的是 2.x 和 2.4 版的混合配置。

從文檔:

因此,即使混合配置仍然是可能的,請在升級時盡量避免它:要么保留舊指令,然后在稍后階段遷移到新指令,要么只是批量遷移所有內容。

從文檔:

在此示例中,沒有身份驗證並且所有請求都被拒絕。

2.2 配置:

Order deny,allow
Deny from all

2.4 配置:

Require all denied

在此示例中,沒有身份驗證並且允許所有請求。

2.2 配置:

Order allow,deny
Allow from all

2.4 配置:

Require all granted

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM