With frameworks like CakePHP it becomes almost impossible to develop proper web applications using a Mac. Below are the instructions to setting up the MAMP stack and creating virtual hosts for multiple projects.

First download MAMP:

Ill say it now, this is by far the best version of the lamp stack you are going to get when working on an Apple laptop. URL: https://www.mamp.info/

Second open preferences and set Apache to listen on port 80

Adding a virtual host in MAMP for Mac

The files that will need editing are opened with Atom from the command line. If that’s not your cup of tea you can replace the atom commands with “nano” or your own preferred text editor.

host file

Open your host file by pasting the following in your terminal:

atom /etc/hosts

You will see something like below. Add a “development” domain name. Just make one up, it will only be locally known to your computer. Be sure to match the ip address with the one before “localhost”. Saving this file will prompt you for your password.

# Host Database
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
## localhost mydomainname.dev broadcasthost
::1 localhost

vhost file

Next, open up your MAMP vhost conf file:

atom /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

Clear al of the file contents and paste the following:

NameVirtualHost *:80
<VirtualHost *:80>
 DocumentRoot /Applications/MAMP/htdocs
 ServerName localhost
<VirtualHost *:80>
 DocumentRoot “/Users/user/my/project/root”
 ServerName mydomainname.dev

For Every domain name you added inside your host file you will need to add a <VirtualHost> block. This block contains your project location and a ServerName. Set the ServerName exactly the same as the domain you added inside your host file and point the DocumentRoot to the root of your project.

Use Atom to open the main Apache configuration file, httpd.conf, which is located at Applications/MAMP/conf/apache/httpd.conf.

Scroll to the bottom of the file and locate the following lines (around 524–525):

# Virtual Hosts

# Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

Remove the hash (pound) sign from the beginning of the line that begins with Include:

Restart Mamp

Restart Mamp. Be sure have a project or index.html file inside your project folder. By browsing to the domain that you configured your project will show. That’s it.