Virtual host for MAMP on Mac OSX

Virtual host for MAMP on Mac OSX

I do this thing around 10th time, how to create a Virtual Host for MAMP stack setup on my Mac. Seems I still need to Google after for some details, so let this article stand for this issue till the end of the times.

So I want to setup a domain alias – a so called Virtual Host – called sandbox.blog.eppz.eu that maps to my local folder ~/MAMP/blog.eppz.eu while all the existing localhost features still working.

Three simple steps: Change default MAMP port to :80, introduce host for OSX, then introduce host for Apache.

Change default MAMP port

Simply set the Apache port in MAMP preferences to 80.Watch out for Skype, it usually sets itself to port :80, better to put it to another one.

Edit hosts file in Mac OSX

Almost every material around suggests to use that weird terminal text editor nano that really chills me out. I prefer use Sublime text for such alterations, “the text editor you’ll fall in love with” they say.

So in finder hit ⇧⌘+G (Go to Folder…), then type /private/etc/hosts.

So in finder hit <strong>⇧⌘+G</strong> (Go to Folder…), then type /private/etc/hosts.” width=”543″ height=”263″ class=”alignnone size-full wp-image-1592 noShadow” /></a></p>
<p>Open the <span class=hosts file in Sublime, then you can add your desired Virtual Host. It will prompt you for administrator credentials on saving, letting you know that you should really know what you’re doing.

Edit hosts file on Mac OSX with Sublime text

Configure Virtual Host for MAMP (Apache actually)

First include the Virtual Hosts MAMP (Apache) configuration file into the main configuration file. Again, hit ⇧⌘+G then go to /Applications/MAMP/conf/apache/httpd.conf.

Once opened you’ll probably find these lines:

So simply uncomment the Include. If you don’t find it, do not hesitate to paste it from here.

Now you’re ready to edit the actual Virtual Host MAMP (Apache) configuration file. Go to /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf.

Being there for the first time you’ll find some examples, so you can simply edit them. Make sure that you create a Virtual Host for localhost itself, too. Also check port numbers to have them :80 as you configured in MAMP settings.

There it goes. Once start you servers, you can see it working like a charm!

Shiny new Virtual Host for MAMP running local.

Hit like below, whether you’re logged in.

Leave a Comment