Setting Up Local Virtual Hosts in MAMP

Posted by on in Blog

The easiest way to set up virtual hosts in MAMP is to use the commercial version of MAMP Pro, which automates & simplifies the process through the MAMP Pro console. 

So if you want lovely/memorable URL's for developing locally on your Mac, here's what you have to do.

Note:
This tutorial is specific to MAMP Pro and may vary for WAMP or other local server set-ups.

MAMP Site Location
Macintosh HD ▸ Applications ▸ MAMP ▸ htdocs ▸ your-site-name

So the /your-site-name/ folder will be the place that your sites files are located.

MAMP Pro vhosts Setup
You need to give yourself a nice URL to connect to your local site in your browser, so do the following:

a) Edit the following httpd.conf file to allow the virtual hosts file to be used by MAMP:

Macintosh HD ▸ Applications ▸ MAMP ▸ conf ▸ apache ▸ httpd.conf

Around line 570, uncomment the following line:

# Virtual hosts
#Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

To:

# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

b) Add a new virtual host in the httpd-vhosts.conf file:

Macintosh HD ▸ Applications ▸ MAMP ▸ conf ▸ apache ▸ extra ▸ httpd-vhosts.conf

Add the following:

NameVirtualHost *:80

<VirtualHost *:80>
   DocumentRoot "/Applications/MAMP/htdocs/your-site-name"
   ServerName local.your-site-name.dev
</VirtualHost>

c) Your Mac’s hosts file

Note:
This is only applicable to MAMP Pro - it may be different in MAMP and/or WAMP.

You do not have to find & edit your Mac’s hosts file - instead, do the following:

In MAMP Pro, you will see a tab called ‘Hosts’. Click this tab & do the following:

  • Click the + to add a new host
  • Give the new host a ‘Server Name’ - in this example, let’s just call it:
  • local.your-site-name.dev (the same as we did in the httpd-vhosts.conf file)
  • Browse to the document root and select the correct folder

 

Restart Apache
Then you can browse your local site at http://local.your-site-name.dev

You're all done... happy surfing & developing locally ;-)

Last modified on
blog comments powered by Disqus

Supporting Partners

stackideas
sobipro
k2
akeebabackup
jomsocial
jce editor

 

Our Preferred Joomla Host's

Web Hosting

Get in Touch With us

For account or Joostrap enquiries, please get in touch with us here.

Contact us