Digital Media Design & Marketing Blog

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:

  1. First let’s make sure that you have MAMP and that you have it installed with the default values for PHP and MySQL.1
  2. Go to the Preference pane and set the default ports.
  3. 2
  4. Open the httpd.conf file by using your spotlight and search for the end of the file:
    3
  5. 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.
  6. Finally set the host file: Open Terminal and type the following:
    sudo nano /etc/hosts
    Password:
  7. Add a new line to your current hosts: 127.0.0.1 alex.dev <!– Remember to use your host name not alex.dev–>
  8. That is it.

Comments are closed.