Problem: You want to host all of your web development sites in ~/Sites, and you don't want to fuck around with DNS and Apache configuration every time you start something new. Solution: DNS wildcards and Apache Virtual Hosting! The easier bit: get dnsmasq going Follow the directions here. Briefly:
- sudo port install dnsmasq
- edit /opt/local/etc/dnsmasq.conf Add address=/.dev/127.0.0.1
- sudo port load dnsmasq
- Add 127.0.0.1 to the operating system's DNS list.
- sudo dscacheutil -flushcache
- ping foo.dev to test it.
NameVirtualHost 127.0.0.1 VirtualDocumentRoot /Path/to/Sites/%-2+"%-2+" is magic: it means the part of the domain name before the last part. For foo.bar.dev it would be foo.bar. Note that if you have Apache's
mod_unique_idenabled you might be getting errors in Apache's log file that look something like this:
[Tue May 14 15:00:02 2013] [alert] (EAI 8)nodename nor servname provided, or not known: mod_unique_id: unable to find IPv4 address of "bernard" Configuration FailedBernard is the local name of my computer. I added an entry in /etc/hosts for bernard, and everything worked out. Magic.