Want each of your local development sites to have their own root and be accessible via the browser with whatever name you choose? Okay.
Install MAMP according to this tutorial.
Note that we’ll want to set Apache and MySQL ports to their defaults (80 and 3306, respectively) – as mentioned in the tutorial.
Now! Much of what I’ll include here was taken from this tutorial, but with a few updates:
We need to open this file:
/Applications/MAMP/conf/apache/httpd.conf
Find the line:
#Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
And remove the hash tag (#), so that the line is evaluated and the extra/httpd-vhosts.conf file runs.
Like the above tutorial, we’ll edit the /etc/hosts file and the /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf file as follows:
/etc/hosts:
127.0.0.1 dev.localhost
127.0.0.1 clientb.localhost
/Applications/MAMP/conf/apache/extra/httpd-vhosts.conf:
NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin webmaster@dummy-host.example.com ServerName localhost ServerAlias *.localhost VirtualDocumentRoot /Users/myname/Sites/%0 RewriteLogLevel 3 RewriteLog "/Applications/MAMP/logs/rewrite.log" <Directory /Users/myname/Sites> Options All AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
Then – create your Site files within this directory (or any other matching the above configuration):
/Users/username/Sites
To match the structure of the /etc/hosts/ file:
dev.localhost
clientb.localhost
Restart the MAMP server and point a browser to http://dev.localhost
.
Now you can add .htaccess
files to be evaluated on a per “site”.
Happy deving.