148

The current version of MAMP that I have only has php 5.2.17 and 5.4.4. I need 5.3.X. Is there a way to add additional versions that can be selected in the MAMP interfaces php preferences? This is for the free version of MAMP, not MAMP PRO.

Thanks

LiveSource
  • 6,230
  • 4
  • 21
  • 20
  • 64
    yes, but there are those of us who would like to know "how to add additional versions of php to MAMP". – frumbert Nov 30 '13 at 08:38

10 Answers10

313

Found a quick fix in the MAMP forums.

Basically it seems MAMP is only allowing 2 versions of PHP to show up. Quick fix, rename the folders you're not bothered about using, for me this meant adding an "X" to my /Applications/MAMP/bin/php/php5.4.10_X folder. Now 5.2.17 and 5.3.20 show up in the mamp prefs.

Done!

Edit - if the PHP version you require isn't in the PHP folder, you can download the version you require from http://www.mamp.info/en/downloads/

Edit - MAMP don't seem to provide links to the alternative PHP versions on the download page any more. Use WayBackMachine https://web.archive.org/web/20180131074715/http://www.mamp.info/en/downloads/

LiveSource
  • 6,230
  • 4
  • 21
  • 20
38

If you need to be able to switch between more than two versions at a time, you can use the following to change the version of PHP manually.

MAMP automatically rewrites the following line in your /Applications/MAMP/conf/apache/httpd.conf file when it restarts based on the settings in preferences. You can comment out this line and add the second one to the end of your file:

# Comment this out just under all the modules loaded
# LoadModule php5_module        /Applications/MAMP/bin/php/php5.x.x/modules/libphp5.so

At the bottom of the httpd.conf file, you'll see where additional configurations are loaded from the extra folder. Add this to the bottom of the httpd.conf file

# PHP Version Change
Include /Applications/MAMP/conf/apache/extra/httpd-php.conf

Then create a new file here: /Applications/MAMP/conf/apache/extra/httpd-php.conf

# Uncomment the version of PHP you want to run with MAMP
# LoadModule php5_module /Applications/MAMP/bin/php/php5.2.17/modules/libphp5.so
# LoadModule php5_module /Applications/MAMP/bin/php/php5.3.27/modules/libphp5.so
# LoadModule php5_module /Applications/MAMP/bin/php/php5.4.19/modules/libphp5.so
LoadModule php5_module /Applications/MAMP/bin/php/php5.5.3/modules/libphp5.so

After you have this setup, just uncomment the version of PHP you want to use and restart the servers!

Will
  • 4,075
  • 1
  • 17
  • 28
onedotover
  • 507
  • 4
  • 3
  • 1
    Tried this with MAMP 1.9.6. Now Apache won't start and I still only see 5.2.17 and 5.3.5. – Bisonbleu Oct 02 '15 at 18:46
  • I can't manage to get another PHP version working. Everytime I try to change it my Apache won't start again. I do see the other PHP versions in the settings, but it only starts MySQL, Apache keeps red. – Snowball Mar 18 '16 at 03:46
  • You don't need to create the extra `http-php.conf` file. You can simply add the PHP version you want to use after the commented line in `http.conf`. Just copy and paste the line and change the version in the path to the version you want. – Will Apr 02 '17 at 03:35
  • Also what if you want Nginx? – Andy Jun 12 '17 at 21:52
  • Works for me. I had to load an old WordPress installation that needed PHP5 to run. My current MAMP out-of-the-box free version gives me two PHP7 versions in MAMP/Preferences/PHP/. Doing the above steps and restarted the server running PHP5 (which is still included in the MAMP bin) and the WordPress installation worked. Did what I needed to do then reverted back. – Kalnode Aug 14 '18 at 00:12
12

I'm using the free version of MAMP on mac (27 of April of 2021, MAMP version 6.3) and the @LiveSource answer helped me to find a solution.

My MAMP is not showing more than 2 option on the dropdown and on the /Applications/MAMP/bin/php has 7 options of PHP version. So the MAMP will display the latest 2.

To solve it I changed the name of all PHP version folders that I would not like to use. This way only 2 folders will be compatible with MAMP and my desired versions will display on the dropdown.

I added a _X in the end but you can add anything.

After doing the change, close the MAMP and open it again.

See the screenshots of the solution working.

enter image description here

enter image description here

Rafael Perozin
  • 573
  • 7
  • 20
  • Rafael Perozin - How can we hack the MAMP to show more than 2 PHP versions in mamp panel and use one of them as per our project's requirements? Renaming php folder is working but it's not good solution with 2 PHP versions limit. Thanks. – Kamlesh Jun 09 '22 at 08:00
  • I'm not sure you can. – Rafael Perozin Jun 09 '22 at 13:16
11

MAMP takes only two highest versions of the PHP in the following folder /Application/MAMP/bin/php

As you can see here highest versions are 7.0.10 and 5.6.25 MAMP php Versions 7.0.10 and 5.6.25

Now 7.0.10 version is removed and as you can see highest two versions are 5.6.25 and 5.5.38 as shown in preferencesphp versions 5.6.25 and 5.5.38

  • 2
    Renaming the php folders say from `php7.0.33` to `_php7.0.33` and restarting MAMP is enough. No reason to remove the directory. – caramba Sep 25 '20 at 10:55
9

First stop the Server if its running. Go to "/Applications/MAMP/bin/", rename the PHP Version you don't need (MAMP is only allowed to use 2 PHP Versions), e.g. "_php5.2.17". Now MAMP will use the php versions that are left. Go to the MAMP Manager and then settings, then switch to the php version you need.

One problem with this solution I encountered was the httpd process (took me a while to figure that out xD). If you have the httpd process running in the background, then the php switch won't work, until you stop those processes (sometimes MAMP has an awkward problem to stop the server, thats why this process can be still alive). Start your Activity Monitor on your Mac (Shortcut: Press Command+Space and type in activity...), go to the Search Function and type in "httpd", close all those processes. Now you should be able to switch your PHP Version with the MAMP Manager.

ioCron
  • 873
  • 8
  • 9
9

Maybe easy like this?

Compiled binaries of the PHP interpreter can be found at http://www.mamp.info/en/ downloads/index.html . Drop this downloaded folder into your /Applications/MAMP/bin/php! directory. Close and re-open your MAMP PRO application. Your new PHP version should now appear in the PHP drop down menu. MAMP PRO will only support PHP versions from the downloads page.

IKavanagh
  • 6,089
  • 11
  • 42
  • 47
Marianne
  • 91
  • 1
  • 1
6

Additional Version of PHP can be installed directly from the APP (using MAMP PRO v5 at least).

Here's how (All Steps):

MAMP PRO --> Preferences --> click [Check Now] to check for updates (even if you have automatic updates enabled!) --> click [Show PHP Versions] --> Install as needed!

Step-by-step screenshots:

MAMP PRO --> Preferences

enter image description here

enter image description here

enter image description here

Chris S
  • 101
  • 1
  • 5
  • I have MAMP5.3. How do I install PHP > 7.3? – Volatil3 Aug 27 '21 at 16:43
  • Thanks for the post of this very more elegant way getting php versions with MAMP Pro. This worked for me (using in MAMP Pro 6.6.2). – CGN Aug 03 '22 at 07:25
  • If you have MAMP Pro you can simply go to PHP in the dashboard and hit the little plus button. It will open the screen you are referring to. https://documentation.mamp.info/en/MAMP-PRO-Mac/Languages/PHP/ – Shawn Hayes Aug 25 '22 at 20:40
4

The easiest solution I found is to just rename the php folder version as such:

  1. Shut down the servers
  2. Rename the folder containing the php version that you don't need in /Applications/MAMP/bin/php. php7.3.9 --> _php7.3.9

That way only two of them will be read by MAMP. Done!

Kamlesh
  • 5,233
  • 39
  • 50
Josep Alsina
  • 2,762
  • 1
  • 16
  • 12
  • Free MAMP only allows 2 PHP versions in drop-down to select one of 2. Thanks Josep. – Kamlesh Aug 08 '22 at 07:54
  • If we want to use / enable lower version of php then first we will have to stop the server then rename one upper activated / enabled version of php folder. Close the MAMP application and restart it. Now you will see set lower version of php in drop down to use it. Happy to help – Kamlesh Aug 08 '22 at 07:57
1

Honestly try using Docker had such a headache with MAMP and php versions.

Use this to get it up and running its simple.

https://github.com/harshalone/docker-compose-lamp

git clone https://github.com/harshalone/docker-compose-lamp.git
cd docker-compose-lamp/
cp sample.env .env
// modify sample.env as needed
docker-compose up -d
// visit localhost

In the bin folder you will see your php versions.

enter image description here

Change the version you want to use in your .env file PHPVERSION=php7.4

You can watch this tutorial. Wish I had started using docker earlier it will save you a tonne of issues and time.

https://www.youtube.com/watch?v=MTeY3npy1gU

user1503606
  • 3,872
  • 13
  • 44
  • 78
-3

The file /Applications/MAMP/bin/mamp/mamp.conf.json holds the MAMP configuration, look for the section:

{
  "name": "PHP",
  "version": "5.6.28, 7.0.20"
}

which lists the the php versions which will be displayed in the GUI, obviously you need to have downloaded the PHP version from the MAMP site first and placed it in /Applications/MAMP/bin/php for this to work.

Alex
  • 9
  • This actually needs renaming the bin/php/phpxx versions folder, otherwise it'll continue to load the higher ones – leopinzon Feb 20 '18 at 14:21