In this tutorial you will learn how to install MAMP on a Mac. If you want to do any development work in PHP and MySQL then you will need to install a server environment which includes Apache and MySQL. The most popular way of doing this is to use a stack such as MAMP.
STEPS TO DOWNLOAD AND INSTALL MAMP ON MAC
STEP 1: Download MAMP
MAMP can be downloaded from https://www.mamp.info/en/. It is a free download although the download package does contain 2 versions - one is the free version and the other is MAMP Pro. However, you can use the free version without any issues and there is no time limit and no restrictions. The Pro version is not required if you simply wish to run PHP scripts and create MySQL databases.
Click on the ‘Free Download’ button.
You will then be presented with the option to download either the Mac or Windows version. Select the Mac version:
The MAMP for MAC download package is approximately 360MB in size so depending on the speed of your internet connection the download may take a minute or two.
STEP 2: Install MAMP
You may wish to consider s computer restart before installing (see my notes at the end of this article). Once MAMP has downloaded, click the download package to start the install process. You will be presented with the standard install process screens.
Click on the Continue button and you will then be presented with the Read Me page which lets you know where the installer will place your MAMP installation. In this case it will be placed in the Applications folder:
You will then be presented with the license agreement. Read the license and, if you accept, click on the Continue button. At this point you will be asked if you agree with the terms of the agreement. Click Agree if you do accept the terms of the agreement.
You will then need to select the disk where you would like to install the MAMP and MAMP PRO software. Note that although MAMP PRO will be installed you will not be charged for it and can delete it if you wish.
Next, you will be notified about the size of the install. The MAMP installation is about 1.5GB on disk. Click on the Install button if you are happy to proceed with the install process.
You will then be asked to enter your computer username and password. Enter your details and click on the Install Software button. Installation may take a few minutes.
If the installation of MAMP is successful then you should see the following:
You can close the above dialog box. You will be asked if you wish to keep the installer or move it to the trash. I, personally, move it to the trash to keep my Mac clutter free. If you wish to do the same then click on the Move to Bin button.
STEP 3: Open MAMP
Go to your Applications folder and look for MAMP. Note that you will have MAMP and MAMP PRO. Click on the MAMP folder and then the MAMP application icon to start MAMP.
STEP 4: Start MAMP
You will now need to start the servers so that you can start using MAMP. You may notice that the Apache Server and MySQL Server indicators are off.
Click on the Start Servers icon and the Apache Server and MySQL Server indicators should turn green.
You may find that your default browser will open to the localhost MAMP page where you will be presented with a welcome page with details about MAMP.
That is it. You are now ready to start using MAMP as your server environment.
HOW DO I START USING MAMP?
The whole reason for installing MAMP was so that you can use PHP code and MySQL. The first thing you should do is start the Apache Server and MySQL Server if you have not already done so.
When you create PHP files these need to be parsed before being served as HTML pages via Apache. This means that you will need to ensure that your PHP files are stored in the root folder of MAMP, otherwise you will find that your files will just be served as text files when you view them in your browser.
There are ways to change the default location of the root folder in MAMP but this can be a little complex for a beginner and is probably best avoided at this stage.
WHERE IS THE ROOT FOLDER IN MAMP?
Your root folder in MAMP is the htdocs folder. If you go to your Applications folder and locate MAMP you will see that your htdocs folder is located within there.
Any files you create should be placed inside this folder. This will ensure that your PHP code is parsed before being served.
HOW DO I VIEW PHP FILES USING MAMP?
Once you have placed your PHP files inside your htdocs folder within the MAMP folder in Applications, it is just a case of opening your preferred browser to view the files.
The default location to view files in MAMP is http://localhost:8888
To get things started you can create a simple hello world script in PHP.
Open your preferred code editor. I use Visual Studio Code but you can any editor you wish.
Type in the following code:
Make sure that you save your file in your htdocs folder and also ensure that you give it a .php extension. For example, I have saved my file as hello.php in my htdocs folder as follows:
Now go to your browser and go to your localhost location at http://localhost:8888. You should see the following:
I suggest that you bookmark this page for quick reference.
If everything is working then you should see the Hello, World! message displayed in your browser.
WHAT ARE THE COMMON ISSUES WHEN INSTALLING MAMP ON MAC?
Not many! Thankfully there are few issues associated with installing MAMP.
You may wish to consider restarting your computer before you install MAMP. In fact, I often recommend this before installing any program. Fortunately, Mac OSX is very stable and I have personally never experienced any issues with installing software. However, I do like to restart my computer before an install.
WHAT ARE THE COMMON ISSUES WHEN USING MAMP ON MAC?
The only issues I have experience with MAMP relate to the starting and stopping of the Apache server and the MySQL server. I usually find that a restart of the computer will solve most issues. If you want to manually stop and restart Apache from the Terminal then you can also do this.
Some users have experience issues with phpMyAdmin, usually relating to being unable to log in. The default solution is to clear your cache and this usually does the trick.
HOW DO I RESTART APACHE ON MAMP?
The easiest way is to use the MAMP interface and just click on the Start / Stop Servers button.
If you would prefer to use the command line then open Terminal and type in the following:
cd /Applications/MAMP/bin
This will take you into the MAMP directory. Then type in the following depending on if you wish to start or stop the Apache and MySQL servers.
To stop Apache and MySQL servers type in the following:
./stop.sh
To start Apache and MySQL servers type in the following:
./start.sh
Feel free to ask any questions about the MAMP installation process in the comments below.
If you would like to learn how to code in PHP then check out the extremely popular PHP for Beginners course where every line of code is explained.