Installing and Using MAMP (Mac Apache MySQL PHP)
What is MAMP?

LAMP is a common acronym for a Linux operating system running an Apache Server, which in turn uses the PHP programming language to pre-process certain files (typically with a ".php" extension) before serving them up, and communicating with a MySQL database to manage data storage and retrieval. MAMP is easy-to-use software that sets up a similar configuration on a Mac operating system instead. The free version of MAMP is more than adequate for learning to use PHP and MySQL in a local environment (eliminating the need to access a remote server to execute your files in a web environment), although they do provide a Pro version with additional features for stable, professional production use.

Downloading and Installing MAMP
Download the File

Visit to download MAMP. As of this writing, you'll see a download link directly in the middle of the screen. (Note that it's for 64 bit systems. If you have an older 32 bit machine, you may be able to poke around on the web to find older versions that will work perfectly well for learning purposes.)

After downloading MAMP, double-click the package that is downloaded and an installer will open. Follow the instructions, accepting all defaults for now. (If the installer you download requires dragging the application into your applications folder as usual, then just do that.)

Once MAMP is installed, you'll be able to start the program by looking for the file in Applications/MAMP/MAMP in your file system. Since you're going to be using it a lot, you might want to drag it out to your launch bar. The program icon looks like this:

images/MAMP_launch_icon.png

Start the program (by clicking the launch icon or double-clicking the program in your file folder). Once it starts up, a screen like this should appear (newer versions may look different):

images/MAMP_start_screen.png

Test the Environment

Once MAMP is installed and has started up (note the start screen, you'll see indicators that the Apache server has started up), you'll need to know where to begin editing files to create your web site(s). The MAMP root directory (again, as of this writing) is installed in /Applications/MAMP/htdocs. Go to this directory and create a file called "test.php". Enter the following code:

Now that you've saved your file. Remember your start screen?...

images/MAMP_start_screen.png

... note the button labeled "Open start page". If you click it, it'll open your browser to an address that looks something like "http://localhost:8888/MAMP/". The "MAMP" part of that is a folder inside of your 'htdocs' folder, so if you back out of that and into "http://localhost:8888/", you'll be looking at the index page for your root directory. So let's enter something like "http://localhost:8888/test.php" (replacing 8888 with whatever port number MAMP set up for you, if any). When you visit that page, you should see something like this:

And that's it! If you see this output as expected, then that means your Apache Server is receiving a request to serve up a PHP page, and is passing the request through a PHP engine to interpret the page first before serving up the output that you see here. If this is the case, the you're ready to continue to...


Recommended next: PHP Programming Basics