Yosemite updates Apache from 2.2 to 2.4
I t copies the old httpd.conf to
/etc/apache2/httpd.conf~previous and replaces it with a vannilla one. Annoying, but not too painful to replace, and it doesn’t touch the vhosts. The list of 2.4 changes doesn’t include anything I actually use. Sadly that doesn’t mean nothing important has changed - rather, they didn’t bother to list things that matter to me.
Apache “directory listing forbidden”
I used to rely on the automatic directory listings generated by mod_autoidex, but they has stopped working. The logs give the message
No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive. “Impossible!” I cry, the settings are right, and they always worked.
This is the DocumentRoot fragment of httpd.conf.
+Indexes is the bit which is supposed to turn on auto-indexing. I use /Library/… for not so important documents I need to put under a webserver for whatever reason.
DocumentRoot "/Library/WebServer/Documents" <directory " library webserver documents"> Options +Indexes +FollowSymLinks # etc </directory>
And this is one of the virtual hosts. For serious dev work, I put my vhosts somewhere other than /Library/…
<virtualhost *:81> DocumentRoot "/pth/to/somewhere/completely/different" ServerName my-virtual-host.dev ErrorLog "/private/var/log/apache2/my-virtual-host.dev-error_log" CustomLog "/private/var/log/apache2/my-virtual-host.dev-access_log" common </virtualhost>
What has changed is that now the options for DocumentRoot don’t automatically carry over to folders which are not subdirectories of DocumentRoot. This can be easily fixed by changing virtual hosts to
<virtualhost *:80> DocumentRoot "/pth/to/somewhere/completely/different" ServerName my-virtual-host.dev ErrorLog "/private/var/log/apache2/my-virtual-host.dev-error_log" CustomLog "/private/var/log/apache2/my-virtual-host.dev-access_log" common <directory " pth to somewhere completely different"> Options +Indexes </directory> </virtualhost>
That proves what the problem is, but it sucks having to do that for every virtual host. The solution is to add the directive for the common parent folder of all my virtual hosts in httpd.conf
<directory " parent of somewhere completely different"> Options +Indexes </directory>
Restart apache and all is well
A fter a
sudo apachectl restart everything works fine.