Setting up a Virtual Host in Mac OS X: The easy way
Ok, so I have been looking around and most people take the long approach to setting up a virtual host in Mac OS X; I am going to do exactly the opposite. Right to the point:
- First let’s make sure that you have MAMP and that you have it installed with the default values for PHP and MySQL.

- Go to the Preference pane and set the default ports.

- Open the httpd.conf file by using your spotlight and search for the end of the file:

- In this case I wanted the virtual host to be alex.dev but you can set it to be whatever you prefer. Also make sure that you set the Document Root properly.
- Finally set the host file: Open Terminal and type the following:
sudo nano /etc/hosts Password: - Add a new line to your current hosts: 127.0.0.1 alex.dev <!– Remember to use your host name not alex.dev–>
- That is it.