【问题标题】:mod_authz_core denied : Laravel 5 + Apache 2.4 + Xampp: showing 403, using ElCapitanmod_authz_core 被拒绝:Laravel 5 + Apache 2.4 + Xampp:显示 403,使用 ElCapitan
【发布时间】:2016-12-22 18:09:26
【问题描述】:

我的 Mac 上有一个新的 Laravel 5 项目。来自 github 的所有内容都已设置并且应该可以工作。运行此命令后,它实际上适用于http://localhost:8000/

php artisan serv

但是,当我想使用虚拟主机时,在浏览器中键入 myprojectname.local 时出现 403 错误。

我在 Php 中有几个 noframework 项目,它们仍然运行良好,我可以使用 otherproject.local 通过我的浏览器 (Chrome) 运行它们因此我不认为 VirtualHosts 是原因。

我正在考虑一个授权问题,所以我检查了我的文件夹的所有者和组(/Users/username/Documents/foldername),但它们与 /private/etc/apache2/httpd.conf 中的配置相似见下文

<IfModule unixd_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User username
Group staff

但是在 XAMPP 和 private/etc 中有太多的“httpd.conf”……我觉得有点失落。

在我的错误日志(我已经在调试模式下设置)这是我看到的:

[Fri Aug 12 16:15:34.606324 2016] [authz_core:debug] [pid 40647] mod_authz_core.c(809): [client ::1:52290] AH01626: authorization result of Require all denied: denied
[Fri Aug 12 16:15:34.606428 2016] [authz_core:debug] [pid 40647] mod_authz_core.c(809): [client ::1:52290] AH01626: authorization result of <RequireAny>: denied
[Fri Aug 12 16:15:34.606436 2016] [authz_core:error] [pid 40647] [client ::1:52290] AH01630: client denied by server configuration: /Users/username/Documents/foldername/public/
[Fri Aug 12 16:15:34.606527 2016] [authz_core:debug] [pid 40647] mod_authz_core.c(809): [client ::1:52290] AH01626: authorization result of Require all granted: granted
[Fri Aug 12 16:15:34.606533 2016] [authz_core:debug] [pid 40647] mod_authz_core.c(809): [client ::1:52290] AH01626: authorization result of <RequireAny>: granted
[Fri Aug 12 16:15:34.606591 2016] [charset_lite:debug] [pid 40647] mod_charset_lite.c(219): [client ::1:52290] AH01448: incomplete configuration: src unspecified, dst unspecified
[Fri Aug 12 16:15:34.607115 2016] [authz_core:debug] [pid 40647] mod_authz_core.c(809): [client ::1:52290] AH01626: authorization result of Require all granted: granted
[Fri Aug 12 16:15:34.607130 2016] [authz_core:debug] [pid 40647] mod_authz_core.c(809): [client ::1:52290] AH01626: authorization result of <RequireAny>: granted
[Fri Aug 12 16:15:34.607139 2016] [charset_lite:debug] [pid 40647] mod_charset_lite.c(219): [client ::1:52290] AH01448: incomplete configuration: src unspecified, dst unspecified

【问题讨论】:

    标签: php laravel xampp apache2 httpd.conf


    【解决方案1】:

    终于知道了:

    1. 我需要修改的文件位于:

    /Applications/XAMPP/xamppfiles/etc/httpd.conf

    1. 我需要在这个文件中添加的是:

       <Directory "/Users/username/Documents/foldername">
           Options +Indexes +FollowSymLinks +MultiViews
           AllowOverride All
           Require all granted 
       </Directory>
      


    说明:

    我之所以需要插入上面的bloc是:在httpd.conf的开头,这部分设置每个文件夹如下:

    <Directory />
        AllowOverride none
        Require all denied
    </Directory>     
    

    这很可能导致 Laravel 被拒绝访问项目文件夹

    现在错误日志看起来不错:

    [Tue Aug 16 14:47:12.326388 2016] [authz_core:debug] [pid 13960] mod_authz_core.c(809): [client ::1:52515] AH01626: authorization result of <RequireAny>: granted
    

    现在来看,困难的部分是在众多同名文件中找到正确的 httpd.conf。我希望它会有所帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-11
      • 1970-01-01
      • 2019-04-16
      • 2016-10-18
      • 1970-01-01
      • 1970-01-01
      • 2015-09-07
      • 1970-01-01
      相关资源
      最近更新 更多