Apache2.4部署django出现403 Forbidden错误解决办法

前言:Apache2.4部署django出现403 Forbidden错误最好要结合apache中的错误日志来观察出现何种错误导致出现403错误

下午百度了一下午没找到解决办法,试了n种方法,简直坑爹!

比如网页出现最多的解决办法是:

<Directory E:/wamp/Apache24/www(你的工程路径)>
           Order allow,deny
           Allow from all
       </Directory>

可惜这样改了后还是报403,最后想起来查看err.log一看报client denied by server configuration: E:/wamp/Apache24/www/www/wsgi.py,当时各种吐血呀,后来还是到开源社区找到一个网页,进去才找到解决办法

方法解决网址:https://mikegriffin.ie/blog/20140130-authz-core-error-client-denied-by-server-configuration/

正文:其实在前面已经把问题说的差不多了,就是在apache的 httpd.conf文件中添加

#添加mod_wsgi.so 模块
LoadModule wsgi_module modules/mod_wsgi.so

#工程中的wsgi文件

WSGIScriptAlias / E:/wamp/Apache24/www/www/wsgi.py

<Directory E:/wamp/Apache24/www>
    Options FollowSymlinks
    AllowOverride none
    Require all granted
</Directory>

然后重启apache,果然解决问题了,原因我这里帮忙贴出来(大致是apache2.3后改动了访问目录权限的方式吧):

I found out that mod_authz_core was introduced in Apache2.3. This changes the way that access control is declared from

  Order allow, deny
Allow from all

to :

  Require all granted

This means that the total configuration for a Directory is now something like:

  <Directory /path/to/directory>
Options FollowSymlinks
AllowOverride none
Require all granted
</Directory>

Restart apache and it'll all work nicely.

上一篇:Ubuntu上通过nginx部署Django笔记


下一篇:Ubuntu16.04 apache2 wsgi 部署django