I’ve said, if it takes you more than 10 minutes to find an answer – it’s your responsibility to document it, and I’ve been slacking.
Today’s issue was enabling virtual hosts on Apache & Mac OS X. Normally not a big deal, but I was stumped for a while by a simple error. Apache would not start, and apachectl was giving me no error.
The workaround to find out what the heck was going on was just to execute httpd directly, which showed me what the problem was:
Syntax error on line 37 of /private/etc/apache2/extra/httpd-vhosts.conf: CustomLog takes two or three arguments, a file name, a custom log format string or format name, and an optional "env=" clause (see docs)
Well the issue is, the default vhosts file on Mac OS X has a misplaced double quote:
CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log common"
Which should be:
CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
of course.
So, the simple instructions:
edit /etc/apache2/httpd.conf and uncomment the line that says:
Include /private/etc/apache2/extra/httpd-vhosts.conf
Now add your virtual hosts by editing the
/etc/apache2/extra/httpd-vhosts.conf file, make sure you place that double quote in the correct place if you’re defining custom log files.
Then run sudo apachectl graceful