Jason Varga

JV Designs Web Design & Development by Jason Varga

Sharing a Local Dev Server with Your Clients Using MAMP

For a while I’ve been trying to figure out the best way to share my local development environment with my clients.
While this may not be the best way, it works for me and may work for you too.
Being a one man shop I don’t feel the need to have a local version then a development or staging version. Just the one works for me.

First of all, you’ll need a Static IP Address. If you don’t have one, you’ll need to talk to your ISP about it.
If you cant get a static IP, then Showoff.io may work better for you.

I use MAMP Pro to manage my local sites.
MAMP allows me to create as many local sites as I want, with as many databases as I need, all using a simple interface. No host file editing necessary.
While all the sites I create with MAMP will work for me, they aren’t going to be visible to anyone else.
To make them visible, I’ll create DNS entries on my website to point to my computer. I’ll also need to set up port forwarding on my modem.

Setting Up MAMP and Creating Local Sites

Once you download and install MAMP, fire it up and you’ll see its interface. There are 2 settings you’ll need to change.

MAMP Settings

You’ll want to change the Apache port to 80 and change the Apache/MySQL user to www/mysql

Click the Hosts tab and this is where you’ll be able to set up all your sites.

MAMP Hosts

Click the + button at the bottom left of the window to add a new host.

While technically MAMP lets you name the server whatever you want, for the external access to work you’ll have to name it as if it were a subdomain of your website. So, for example I would name it sitename.jvdesigns.com.au.
Then just browse to the directory your site is in.

MAMP Hosts

Hit Apply, it’ll ask if you want to restart the servers. Enter your password and it should be ready to go.
Try to enter the server address in your browser. If all goes well, you should see your new site.

You’re ready to develop your site locally now.

Setting up DNS entries

I use Media Temple (mt) as my host and DNS server. What you see here may be different for you but the idea is the essentially the same wherever you are.

First thing to do is edit your DNS Zone file. In your (mt) AccountCenter, it’ll be near the bottom of your main domain control panel.
In your zone file, you’ll probably see a lot of entries already. Leave everything alone.

You’ll need to add an A Record.

Media Temple DNS Zone File

In (mt), click + Add a record.
The name of the record will be the server name you entered into MAMP earlier. (sitename.jvdesigns.com.au) Remember, this should have been a subdomain address of your site.
The type is A
The address or data should be your static IP address. You can find your IP address at What’s My IP.org
Save, and you’re done with your zone file. At the moment, you wont see any progress. DNS entries can take a while to propagate throughout the internet.

Setting up Port Forwarding

What we’ve done so far is told the internet that sitename.jvdesigns.com.au should point to your IP address. This is great but once the request comes to your router, we’ll need to point it to your computer which is holding the site.

This part will be different depending on the router you’re using but essentially its the same thing for everyone.

First of all, your computer running MAMP will have to have a static address, not automatically assigned by DHCP.
To do this:

  • Go to System Preferences
  • Network
  • Choose your internet connection
  • click Advanced… in the bottom right
  • Go to the TCP/IP tab and take note of the IPv4 address
  • Configure IPv4 to either DHCP with manual address or Manually
  • Enter the IPv4 address

Then to set up port forwarding, log in to your router and you’ll need to find a Port Forwarding section. Sometimes, its combined with Port Triggering.

Port Forwarding

Create a new service and enter the following:

  • Start port: 80
  • End port: 80
  • Server IP address: the IP of your computer with MAMP

Your router may reboot after this.

Give it a whirl

Assuming everything has gone according to plan, you should be ready to go now.

To test it out, try to hit the address from a browser outside of your local network.
Remember, DNS may take up to 48 hours to propagate.
You can flush your local DNS on a Mac by opening up terminal and typing dscacheutil -flushcache or on a PC by opening command prompt and typing ipconfig /flushdns.

Comments

Share your thoughts

There are 5 responses to this post.

Legend! This is just what I needed to find out. Great walk through, and really helpful info.

Great article man! Glad you got around to writing it.

Thanks so much for this article, this just made testing a mobile site we’re working on so much easier!

One question though, is there any way for other computers on your network to access via that domain? For example if type domain.ivesetup.com into another computer here it doesn’t work (because it’s on the same network) but if I use a 3G connection instead it works.

Thanks again!

Hey Ben,

I had that issue as well at one time. I’m not sure if you’re seeing it for the same reason, but I did find a way around it.
My modem is a router, as well as my Wifi router which I did all the port forwarding stuff in the article. I had to make sure that my modem was in bridge mode. I think if the modem tries to do any routing of its own, you’ll run into that problem. Once I changed it to bridge mode, everything seemed to work out.

Another thing you might want to do is edit the hosts file on the other computer. I do this for my Parallels VMs. Add an entry that points to your server computer.

Thanks Jason, I’ll check it out and see if it’s anything to do with Bridge mode. I have a bit of a funny setup as our router controls everything, but I have Time Capsule which handles the WiFi side of things.

Host file can work well unfortunately I need to test on multiple mobile devices so can’t do that for them!

Thanks again for the great article.