Apache2 "Require all granted" doesn't work

I have a fresh install of Apache2 on Debian testing and configured a virtual host in a directory like this:

<Directory "/path/to/project">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted
</Directory>

However it shows me a 403 Forbidden error when I access it and the error log shows:

[Mon Sep 23 22:07:57.249276 2013] [authz_core:debug] [pid 8599] mod_authz_core.c(802): [client 127.0.0.1:49057] AH01626: authorization result of Require all denied: denied
[Mon Sep 23 22:07:57.249349 2013] [authz_core:debug] [pid 8599] mod_authz_core.c(802): [client 127.0.0.1:49057] AH01626: authorization result of <RequireAny>: denied
[Mon Sep 23 22:07:57.249361 2013] [authz_core:error] [pid 8599] [client 127.0.0.1:49057] AH01630: client denied by server configuration: /path/to/project/some_file

Why is it showing "result of Require all denied: denied" if I'm using "Require all granted"?

They files are readable by any user and just in case I tried changing the owner to Apache (www-data) without luck. Also, the default host on http://localhost works normally and phpmyadmin in http://localhost/phpmyadmin works too.

All help I've found on the Internet is about replacing the Order directive with Require. I've already done that. What could be the problem now?


Solution 1:

Here are two things to try:

1) Run apachectl -t to check the syntax of your file is valid.

2) Run apachectl -S to show which files are being parsed.

For example, you may be editing /usr/local/etc/apache2/2.4/httpd.conf and that's it right? ...but if you run apachectl -S you might see:

VirtualHost configuration:
*:80                   localhost (/private/etc/apache2/extra/httpd-vhosts.conf:23)

ie. The virtual host is overriding your httpd.conf, and may contain its own Require all denied or similar.

Solution 2:

You have set up authorization, but no authentication. So while the 'Require all granted' will give all authenticated users access, your users don't actually authenticate.

Solution 3:

Since you're using the AllowOverride All directive, you may also have an .htaccess file in /path/to/project/. This one may contain an overriden directive.

Check also if you don't don't have some other parameter in a VHost for exemple.

Solution 4:

After having installed Wampserver 32, I have had the same issue of being rejected by Apache.

I have checked and try to modify the httpd.conf file in many ways for 3 days with no luck, going all around the Apache tutorials and Internet forums with the famous error:

AH01630: client denied by server configuration

I was quite sure I did not define any VirtualHost and none was to be seen in the httpd.conf file.

Finally, I configured the server for "debug" error file, which gave me the more interesting message:

AH01626: authorization result of Require local : denied

which in turn lead me to this post.

And there it was, hidden in the C:\wamp\bin\apache\apache2.4.18\conf\extra\httpd-vhosts.conf file: an undesired VirtualHost with an explicit "Require local" which of course rejected all my queries from outside the server.

Now, I have emptied this file until I may need any VirtualHost, and it works fine. In the end, I find it rather strange from Wampserver to not only pre-configure this file without notifying the user but to set the default value so that the "server" cannot serve anything.