1. Freebies
  2. Tutorial
  3. MAMP Basics - Build a Local Environment
MAMP Basics - Build a Local Environment
Tweet Like

MAMP Basics - Build a Local Environment

A testing server is an important tool for any designer or developer. This web development tutorial will show you how to install MAMP and get it running in no time.

More specifically, this MAMP tutorial will show you how to build a virtual web server on your computer in just a few easy steps. This will allow you to test all of your websites completely offline (which is a clutch tool for any web developer). Lets get started so you can get coding and testing like a boss!

Setting Up Mamp

It's easier then you'd think - To set up MAMP all you'll need is the latest version of MAMP (available at www.mamp.info) and a simple text editor to address the code. Text Wrangler, TextMate, Jedit, or Coda would all do the job well and you could always just use Terminal if you're really hardcore. Once you've downloaded MAMP (you know the drill) - Just install MAMP by unzipping it and dropping it into your "Applications" folder. Before we go any further, it's important to get a little info on exactly what you'll be doing.

Install MAMP - MAMP Logo

Server Testing Basics

What we're basically doing is creating our own "internet". The primary advantage that we're using is the privacy that this allows. I'm certain that I'm not the only dev nerd who used to anxiously approach code changes on live sites. When you're just starting off it's absolutely nerve racking. By having your own internet running, you don't need to worry about clients monitoring your revisions or even worse - breaking some part of a live website (don't lie - we've all missed a few div's in our day). The concept of a local testing server sounds complex, but really it just gives beginning coders exactly what they need - Practice!

As for MAMP, If you look at the name it'll tell you exactly what it is - Mac Apache Mysql PHP. Those last three are obviously the important ones here and if you don't know, those are some of the basic building blocks of the internet. Simply - Apache is your testing server, MYSQL is your database, and PHP is your scripting language (which is great being that most major CMS's run on a PHP backbone - Wordpress, Joomla, Drupal, CodeIgnitor etc.). That covers the functional aspects and brings me to the inherent problem.

IMPORTANT: When running the MAMP application, you are broadcasting a network. If you are connected to the internet while you're broadcasting, you are leaving your door WIDE open to hacker types.

Securing MAMP

All MAMP applications come setup with the same username and password (hint: They're both "root"). As you can imagine - if they're is anything worse then "broadcasting" your network to the public, it's broadcasting your network to the public with a default username and password. So the final step in our tutorial is addressing just that problem.

Go ahead and start MAMP, then go to your /Applications/Utilities folder and open up Terminal. Don't be scared, just take your time and make sure you input this one part correctly. From your root, you'll need to type...

/Applications/MAMP/Library/bin/mysqladmin -u root -p password [NEWPASSWORD]

Once you hit enter, you'll be prompted for the current password (which is "root"). As long as you don't get an error, you've successfully reset your root users password. The next file you'll need to edit is "config.inc.php" that can be located at /MAMP/bin/phpmyadmin/config.inc.php. Open that file with your trusty text editor and look for the line that reads...

$cfg['Servers'][$i]['password']   = 'root'; 

MAMP Additional Fixes...it should be near the 86th line down. Change that "root" to your new password and save.

The last few files that you'll need to change are located in /MAMP/bin/. The file names are checkMysql.sh, quickCheckMysqlUpgrade.sh, repairMysql.sh, stopMysql.sh, and upgradeMysql.sh and it should look awfully similar to the image that's attached to the right. These files (as you can probably gather) handle the stopping, starting, etc. of MAMP and that's why they're important to edit. If you don't get around to fixing these, you can have a network running that you're not even aware of... Which obviously isn't good (ps. I've also heard of some setups that require you do the same change to "bin/mamp/index"). Now each of these files will have a line that reads...

-u root -p root

This is simply a block stating "Ok, this is the user and this is the password". When replacing the "root" password here, you do need to do one thing slightly different. When you replace the password, remove the space between "-p" and your new password (it should read -pNEWPASSWORD). Once you've edited these files, you have properly reset your root password and you're ready to roll!

Now Have a Ball

MAMP Ports

You should have everything up and running now. Now keep in mind, you still want to turn your network connection off when you're running MAMP. Resetting the password will allow you to remove your "low-hanging-fruit" status, but you're still broadcasting a network. If you'd like to remove the ":8888" that you see at the end of your URL, just open up MAMP preferences and click "Set to default Apache and Mysql ports" (see picture). You'll also notice that you can change your document root under the "Apache" tab (otherwise it defaults to /MAMP/htdocs.

Every setup is a little unique, but now you should have a functional testing server for you to practice all your coding awesomeness on... HTML, Wordpress, Drupal, Joomla, whatever you want. Now pat yourself on the back, Share this post on your social networks ;), and feel free to leave any comments or tips you may have below.

Need a video walk through? Click on "In Video" below and check out the step by step process - courtesy of Jono Young (@chsweb).

Related Articles
  • Apple Security for Yosemite and Beyond
  • Dropbox Database Sync for Testing
  • Free Site Ranking Utilities
  • Make Custom Facebook Fanpages
  • Mastering RSS - RSS Submission Sites & Tools
Written By:
Matthew Haeck
Raleigh, NC

Matthew Haeck is the lead designer and developer at Haeck Design. His educational background in both Graphic Design and Economics prepared him perfectly to operate the design firm which bares his name. When not working, Matthew enjoys curating his growing vinyl collection, hitting the beach, and supporting his beloved hometown of Raleigh, NC.