mod_authz_core denied: Laravel 5 + Apache 2.4 + Xampp:显示403,


mod_authz_core denied : Laravel 5 + Apache 2.4 + Xampp: showing 403, using ElCapitan

我的Mac上有一个新的Laravel 5项目。github上的所有内容都设置好了,应该可以工作。运行以下命令后,它实际上可以在http://localhost:8000/上工作:

php artisan serv

但是,当我输入myprojectname时,我看到403错误。当我想使用虚拟主机时,在浏览器中本地。

我在Php中有几个无框架项目,它们仍然工作得很好,我可以通过我的浏览器(Chrome)使用otherproject运行它们。所以我不认为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 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

终于发现了:

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

/应用程序/XAMPP/xamppfiles/etc/httpd . conf

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

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

  • 解释:

    我需要插入上述代码块的原因是:在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。