How to properly set the allow and deny for apache 2.4 conf and vhosts

Viewed 22

I need some advice on how to properly setup the vhosts file directives preferably without changing the apache2.conf contents. This is for apache 2.4.

Currently, I get AH01797: client denied by server configuration probably caused by the Require all denied in the apache2.conf.

apache2.conf:

<Directory />
        Order Deny,Allow
        Deny from all
        Options None
        AllowOverride None
        Require all denied
</Directory>

vhosts file:

<IfModule mod_ssl.c>
    <VirtualHost *:80>
        ServerName sub.example.com
        ServerAlias sub.example.com
        <Directory /var/www/sub.example.com>
                AllowOverride None
                Allow from all
                Require all granted  
        </Directory>
    </VirtualHost>
</IfModule>

Thank you!

UPDATE Adding this to the apache2.conf works, it just doesn't work in vhosts file. Any idea why?

<Directory /var/www/tollbg.cargenta.com>
        AllowOverride None
        Allow from all
        Require all granted
</Directory>
0 Answers
Related