Changing the Default PHP Version in MAMP

When doing any development on my laptop I use the very useful MAMP to give me an xAMP (Apache, MySQL & PHP) environment.

I recently upgraded and found that the free version offers two versions of PHP: 7.4.33 and 8.2.0 which would be fine but my production server is still on 8.1 and so I needed to match that. I could have upgraded to MAMP Pro but £90 just to switch to PHP 8.1 seemed a bit much, although, I do appreciate that by doing so I would be supporting the developers.

Changing the PHP Versions in MAMP Free Edition

It turns out that changing the versions available to you in the MAMP free edition is pretty straight forward. By default MAMP shows you the latest version for the last two releases that it is shipped with which is currently 7.4.33 and 8.2.0.

The versions of PHP that are available to you are held (on a Mac) in:

/Applications/MAMP/bin/php

Go to this location and rename the php8.2.0 folder (I just added a hypen at the beginning) and then restart MAMP. I wouldn’t recommend removing the folder completely as you may wish to come back to it in future.

Now MAMP will offer you two versions of PHP: 7.4.33 and 8.1.13.

You can check that it has worked by running the following command and the version is shown at the very top of the page.

<?php
    phpinfo();
?>

Leave a Reply

Your email address will not be published. Required fields are marked *