VirtualHost's on MAMP,WAMP,XAMMP, etc: (Great for Drupal Multisite!)

I wrote a little tutorial on setting up your hosts file and vhosts, this can easily be transfered to the all-in-one package of your liking or whatever else it is. This one was meant for OSX and MAMP but all files such as httpd.conf and hosts can be transfered from PC and MAC as well as MAMP, WAMP, XAMP, etc... hope it saves you a headache!

 

This setup will allow you to create virtual hosts on your local machine
which will benefit in a multisite setup with Drupal.

1. Open your httpd.conf
    This file will reside in /Applications/MAMP/conf/apache/httpd.conf .
    
2. Go to the bottom of httpd.conf until you find a header that looks similar to this:
    <VirtualHost 127.0.0.1>
        DocumentRoot /Applications/MAMP/htdocs
        ServerName localhost   
    </VirtualHost>
   
    Add a new Virtual host underneath this one:
   
    <VirtualHost *>
        DocumentRoot /Applications/MAMP/htdocs/path/to/folder
        ServerName yoursitename.local
    </VirtualHost>
   
    *** Notice the path name, the path to your site folder;
     as well as the asterisk *, which allows a global connection.
   
3. Save the file and open terminal.
    In terminal, locate and open the hosts file. This file is usually hidden
    and will be inaccessible through finder.
   
    At the prompt, type in the follow:
   
    :~ user$ open /etc/hosts
   
    If you do not have a default text browser defined with your system, you can open the file
    through terminal by using:
   
    :~ user$ nano /etc/hosts
   
4. Once the file is open, you should see a document similar to this:

    ##
    # Host Database
    #
    # localhost is used to configure the loopback interface
    # when the system is booting.  Do not change this entry.
    ##
    127.0.0.1 localhost
    255.255.255.255    broadcasthost
    ::1             localhost
   
5. We will now add your hostname. We can do this one of 2 ways:

    We can append it to the pre-existing 127.0.0.1 like so:
    127.0.0.1 localhost yoursitename.local
   
    Or add another line beneath it:
    127.0.0.1 localhost
    127.0.0.1 yoursitename.local
   
    *** Note: yoursitename.local must be identical to the one you setup in your httpd.conf file
                under VirtualHosts otherwise this will not work properly.
               
6. Save the file, start up MAMP or restart depending on if you've had it running already.