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.
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.
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.
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).
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
5. Restart and verify
Restart MAMP services.
In order to verify that all is well, point your web browser to:
http://localhost2:8888/
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.
Leave a Reply