I have the following in apache.conf on my development workstation (actually included from /etc/apache2/users/andrew.conf):
<Directory "/Users/andrew/Sites/"> Options Indexes MultiViews AllowOverride All Order allow,deny Allow from all </Directory> <VirtualHost *:80> DocumentRoot /Users/andrew/Sites/mysite/public ServerName mysite.dev </VirtualHost>
I'm relying on the default settings in my new install of Mac OS X Lion, and just adding the VirtualHost directive.
When I get http://localhost/~andrew/ It doesn't try to serve the standard Directory index, rather it tries to serve the VirtualHost instead. I would expect this to happen only when accessing it by the ServerName "mysite.dev".
If I remove the VirtualHost, it serves the Directory index correctly.
Any ideas why this might be happening?
Update: I found that if I move the VirtualHost directive from users/andrew.conf to extra/http-vhosts.conf, then it works properly. I suppose that answers my question, but I'm still not clear on the root cause:
## httpd.conf Include /private/etc/apache2/extra/httpd-userdir.conf Include /private/etc/apache2/extra/httpd-vhosts.conf ## extra/http-userdir.conf UserDir Sites Include /private/etc/apache2/users/*.conf <IfModule bonjour_module> RegisterUserSite customized-users </IfModule> ## extra/httpd-vhosts.conf NameVirtualHost *:80
The configuration looks like they should still load the same thing, so I don't see why it would make a difference whether my VirtualHost is defined in extra/httpd-vhosts.conf or in my own users/andrew.conf
Update 2: In the extra/httpd-vhosts.conf file, I had commented out the "example" VirtualHosts that point to non-existent DocumentRoots. By putting these examples back in, my regular Directories now work as expected without falling through into the first catch-all VirtualHost.
So, the real question is: why does the apache configuration need an invalid VirtualHost for this to work?