I just spent a good hour trying to work out why virtual hosts wasn’t working for me on my local machine. Turns out I needed to:
1) Enable virtual hosts by uncommenting the line
Include /private/etc/apache2/extra/httpd-vhosts.conf
in httpd.conf
2) Add the line
NameVirtualHost 127.0.0.1
to httpd.conf. I put it under the line
Listen 80
for now.
then…
3) Add my new hosts to the bottom of the httpd-vhosts.conf file:
<virtualhost mylocalsite.hjb> DocumentRoot /Volumes/Drive/Sites/mylocalsite ServerName mylocalsite.hjb ServerAlias *.mylocalsite.hjb </virtualhost>
4) Add the sites as new lines to the /private/etc/hosts file as
127.0.0.1 mylocalsite.hjb
You can also do this with subdomains if you like. subdomain.mylocalsite.hjb