前言: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 allto :
Require all grantedThis 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.
新聞熱點
疑難解答