apache: don't have permission to access / on this server. when I am using virtualhost

apache, vhosts

Solution

In `http.conf` file you should define options for only `<Directory />`. All the options of VirtualHosts you should define in `httpd-vhosts.conf` files. Something like:

httpd.conf:

DocumentRoot "/var/www"

<Directory />
        Order deny,allow
        Deny from all
        Options None
        AllowOverride None
</Directory>

httpd-vhosts.conf:

ServerName aaa.com
DocumentRoot /var/www

<Directory /var/www>
        Options FollowSymLinks Includes
        AllowOverride All
        Order allow,deny
        Allow from all
</Directory>

Problem

For example, the document root of `virtualHost` is `/var/www`, and server name is `aaa.com`. However, apache will tell me `forbidden` if I access the server with `localhost` and `aaa.com`. If I change the `Directory` option in `http.conf` to `/var/www`, apache will work well. I don't know why? I want to set `Directory` option in every `httpd-vhosts.conf`, not in `httpd.conf`, how I can do it? Here is my `http.conf`: Here is my `httpd-vhosts.conf`:

Original source