Digital Masters Magazine

Home of Digital Masters

  • Design
  • Photo
  • Video
  • Web
  • Code
  • UX
  • Mobile
Home Code Setting Up Apache Virtual Hosts on MAMP
Setting Up Apache Virtual Hosts on MAMP

May 8, 2011 By Digital Masters Leave a Comment

Setting Up Apache Virtual Hosts on MAMP

In order to comfortably edit several dynamic websites in Dreamweaver at the same time you do not need several teting servers. Instead, you can set up virtual hosts on your existing Apache installation. This will work with any popular distribution including MAMP, WAMP and XAMP. Today we will show you how to set up virtual hosts on MAMP.

1. Install MAMP

First, go to the official MAMP website and download your free copy of MAMP. Unzip the packgage, double-click the installer and follow the on-screen instructions.

MAMP installation
Installing MAMP and MAMP Pro

At this point, you should have a working installation of Apache with MySQL.
In order to manage your servers, locate a folder named MAMP in your Applications folder and double-click MAMP.app.

MAMP: stop servers
MAMP: stop servers

In order to complete the other steps you should stop your servers now.

2. Edit /etc/hosts on your Mac

Open the Terminal and type

sudo pico /etc/hosts

When prompted, enter the password of your administrator account.

Edit the file in a way that you see a result like 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 localhost2 localhost3
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost

Instead of localhost, localhost2, localhost3 you could actually put in the name of a project.

editing /etc/hosts on MAc OS X
editing /etc/hosts on Mac OS X

When you are done editing the /etc/hosts file, press Control-O in order to output your changes to the file.  When prompted to overwrite existing file, confirm with Return. The editor will overwrite the existing /etc/hosts file. Press Control-X to exit pico.

3. Edit the the httpd.conf file

Open the file httpd.conf located in /Applications/MAMP/conf/apache in a text editor of your choice (either TextEdit in plain text mode, TextWrangler or BBEdit will do).

Path to your Apache files in MAMP on OS X
Path to your Apache files in MAMP on OS X

Open the file httpd.conf located in /Applications/MAMP/conf/apache in a text editor of your choice (either TextEdit or BBEdit will do).

Navigate to the end of that file and enter this:

#NameVirtualHost *:8888
Include /Applications/MAMP/conf/apache/vhosts.conf

This will ensure that Apache reads the contents of the vhosts.conf file you are going to create.

3. Create your vhosts.conf file

Create a new text file and save it in the Include path you defined in the previous step. Enter in it this code:

# Virtual Hosts
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any block.
#
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot "/www/docs/dummy-host.example.com"
# ServerName dummy-host.example.com
# ServerAlias www.dummy-host.example.com
# ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
# CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log common"
#
# ServerAdmin webmaster@dummy-host2.example.com
# DocumentRoot "/www/docs/dummy-host2.example.com"
# ServerName dummy-host2.example.com
# ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
# CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log common"

ServerName localhost
DocumentRoot /Applications/MAMP/htdocs/

Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all

ServerName localhost2
DocumentRoot /Applications/MAMP/htdocs2/

Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all

ServerName localhost3
DocumentRoot /Applications/MAMP/htdocs3/

Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

Save the file.

4. Create directories for virtual hosts

In Finder, navigate to /Applications/MAMP/. Create directories which will serve as documents folders for your virtual hosts:

htdocs2
htdocs3

MAMP Server path on Mac OS X
The location of MAMP Server on Mac OS X

5. Restart and verify

Restart MAMP services.
In order to verify that all is well, point your web browser to:
http://localhost2:8888/

MAMP success
This is what you will see when your configuration works out.

If you see anything at all which isn’t an error message of your browser, for example if you see this information:

Index of /
Apache/2.0.64 (Unix) PHP/5.3.5 DAV/2 Server at localhost2 Port 8888

you are done!
Now you can begin setting up Dreamweaver in order to use your new virtual hosts as testing servers for dynamic web pages.

Filed Under: Code, Web Tagged With: Adobe, Apache, Dreamweaver, Mac, MAMP, virtual hosts

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Treat yourself to the best of our content

Courtesy of our friends at substackapi.com

Manhattan beauty

Is this your cup of AI?

Speed is everything: shiny car engine rendering

How to force an older PC to upgrade Windows 10 to Windows 11 when it refuses to go along for the ride

Photo by Warren Wong on Unsplash

The tech revolt. Say goodbye to your favorite search engine that’s been wasting your precious clicks on silly captchas

Change language settings in Adobe Photoshop 2020

How to change the language of Adobe Photoshop

Apple MacBook Pro (16-Inch, 16GB RAM, 1TB Storage) - Space Gray

The new 16-inch MacBook Pro: Faster, slightly heavier but still ultra-light and #WorthTheWait

Change language settings in Adobe Photoshop 2020

If you want to run any of your apps of the Adobe Creative Cloud in another language, you have come to the right place. (There is no need to purchase another license; this is just a setting of your current install.)

Apple MacBook Pro (16-Inch, 16GB RAM, 1TB Storage) - Space Gray

Apple’s new 16-inch MacBook Pro sports even cooler looks than its predecessor. It is also truly different.

What’s up

ActionScript Adobe Adobe CC All-in-One WP Migration Angular 2 Apache Apple assistive technology Belarc Advisor bootable Windows 10 Upgrade DVD crawl disabilities DNG Download tool now Dreamweaver Event Viewer Google GPU HTML iOS iPhone JavaScript Microsoft Windows 10 OpenSSH OS X PayPal performance photos Photoshop PHP product key RAW RSS SEO speed SSD Tim Cook TypeScript upgrade deadline Wall Street Windows Windows 10 Windows 10 Fall Creator's Update Windows 10 free upgrade WordPress

Categories

  • Home
  • Subscribe
  • Advertise
  • Privacy Policy
  • Legal
  • Contact Us

Copyright © 2025 ·Streamline Pro Theme · Genesis Framework by StudioPress · WordPress · Log in