Install homebrew
ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
brew install dnsmasq
sudo cp "/usr/local/Cellar/dnsmasq/2.75/homebrew.mxcl.dnsmasq.plist" "/Library/LaunchDaemons"
sudo launchctl load -w "/Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist"
mkdir -p /usr/local/etc/
echo "address=/dev/127.0.0.1" >> /usr/local/etc/dnsmasq.conf
echo "address=/devs/127.0.0.1" >> /usr/local/etc/dnsmasq.conf
sudo -s
sudo mkdir -p /etc/resolver
sudo echo 'nameserver 127.0.0.1' > /etc/resolver/dev
sudo echo 'nameserver 127.0.0.1' >> /etc/resolver/devs
# flush cache
dscacheutil -flushcache
# ensure it works
scutil --dns
sudo vim /etc/apache2/httpd.conf
Change the line
# LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so
To
LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so
And exit vim
Edit the file
sudo vim /etc/apache2/extra/httpd-vhosts.conf
Empty the file and insert the code snippet from below.
<Directory "/Users/YOU/www">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Require all granted
</Directory>
UseCanonicalName Off
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog /var/log/apache2/access_log vcommon
<VirtualHost *:80>
VirtualDocumentRoot "/Users/YOU/www/%1/%-2/web"
ServerName sites.devs
ServerAlias *.devs
DirectoryIndex app_dev.php index_dev.php app.php index.php
ErrorLog "/var/log/apache2/vhost-error_log"
CustomLog "/var/log/apache2/vhost-access_log" common
UseCanonicalName off
</VirtualHost>
<VirtualHost *:80>
VirtualDocumentRoot "/Users/YOU/www/%1/%-2"
ServerName dev
ServerAlias *.dev
DirectoryIndex index.php index.html
ErrorLog "/var/log/apache2/vhost-error_log"
CustomLog "/var/log/apache2/vhost-access_log" common
UseCanonicalName off
</VirtualHost>
You will access the sites with the following examples. The sites with index.php etc. under the web folder, will be accessed with the tld .devs
the other with .dev
http://customer1.site1.dev
http://customer1.site2.devs
http://customer3.site7.devs
www
├── customer1
│ ├── site1
│ │ └── index.html
│ ├── site2
│ │ └── web
│ │ └── index.php
│ └── site3
│ └── web
│ └── app_dev.php
├── customer2
│ ├── site4
│ │ └── web
│ └── site5
└── customer3
├── site6
├── site7
│ └── web
│ └── app_dev.php
└── site8
└── web
└── app_dev.php