Skip to content

Instantly share code, notes, and snippets.

@jbottigliero
Created June 28, 2012 21:46
Show Gist options
  • Save jbottigliero/3014151 to your computer and use it in GitHub Desktop.
Save jbottigliero/3014151 to your computer and use it in GitHub Desktop.
MAMP : Virtual Hosts
# Backup your host file
sudo cp /etc/hosts /etc/hosts.bak
# Edit your host file
# See 'hosts.example' for example contents
vim /etc/hosts
# Edit MAMP Apache configuration to include Virtual Hosts configuration
# See 'httpd.conf.example' for contents changes
vim /Applications/MAMP/conf/apache/httpd.conf
# Edit MAMP Virtual Hosts configuration
# See '/httpd-vhosts.conf.example' for changes
vim /Application/MAMP/conf/apache/extras/httpd-vhosts.conf
# Restart MAMP!
# To make the new virtual host accessible to an internal Virtual Box
# Update the hosts file (Windows)
{system}/system32/drivers/etc/hosts
# EXAMPLE
10.0.2.2 example
# Access in browser using
http://example:8888/
##
# 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
fe80::1%lo0 localhost
127.0.0.1 example
# Make sure the following line is uncommented:
NameVirtualHost *
# Add your Virtual Hosts
<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs/"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs/example/"
ServerName example
</VirtualHost>
...
# At ~524 uncomment the following line:
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
# If using .htaccess files you'll want to AllowOveride in your DocumentRoot Directory, the following starts line ~212.
# The only value you'll need to change is actually around line
...
<Directory "/Applications/MAMP/htdocs/">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options All
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment