How to change PHP version on MAMP 4.1

How to change PHP version on MAMP 4.1

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

How to change PHP version on MAMP 4.1

MAMP 4.1 ships with a curated list of PHP binaries, typically defaulting to versions 7.0.15 and 7.1.1 for Mac users. While this setup simplifies initial configuration, it locks you into specific runtimes that may not align with legacy project requirements or specific extension needs. If your stack requires PHP 5.6—a version often found in older Laravel applications or legacy CMS platforms—you cannot simply toggle a switch within the MAMP Preferences panel. The application is designed to use only the binaries included in its installer bundle, meaning you must manually inject the desired runtime into the system path MAMP scans.

The most direct approach involves bypassing the GUI selection entirely and configuring MAMP to locate your custom PHP installation via command-line arguments. This method relies on the fact that MAMP respects environment variables and specific path definitions when launching its server processes.

To begin, you need a valid PHP 5.6 build installed on your Mac. Since MAMP 4.1 does not include this version in its standard distribution, you will likely need to compile it from source or download a pre-compiled binary from a trusted repository like Homebrew or Pecl. Once installed, verify the binary works by running php -v in your terminal. Ensure you have a matching php.ini file ready, as MAMP looks for this configuration relative to the executable path unless specified otherwise.

The core of the solution lies in modifying the startup scripts that launch the Apache and MySQL services. MAMP uses specific shell scripts located within its installation directory (usually /Applications/MAMP/bin/mamp/bin). You need to edit these files to prepend your PHP 5.6 binary path before the default one.

For example, open the start-server script using a text editor:

vi /Applications/MAMP/bin/mamp/bin/start-server

Locate the line where MAMP executes its PHP logic or where it invokes the system's /usr/bin/env php. You will often see a command structure resembling this:

/usr/bin/env php "$1" -t "$2" "$3" "$4" "$5" "$6"

To inject PHP 5.6, you must replace the generic call with an explicit path to your new binary. If your PHP 5.6 is installed at /usr/local/php56/bin/php, the line should look like this:

/usr/local/php56/bin/php "$1" -t "$2" "$3" "$4" "$5" "$6"

You must apply identical changes to both start-server and stop-server scripts, as well as restart-server. Additionally, check the setenv script if present, ensuring it does not hardcode paths to the older versions.

If you encounter issues where MAMP still defaults to the bundled PHP, ensure that your custom binary is in your system's $PATH ahead of the standard /usr/bin/php. You can verify this by running which php before starting MAMP; it should return the path to your 5.6 installation.

A critical consideration when switching PHP versions on MAMP is extension compatibility. PHP 5.6 lacks support for modern extensions like bcmath or mbstring in their latest iterations, and libraries written for PHP 7 may fail to load due to opcode cache incompatibilities (e.g., OPcache parameters). When deploying a legacy project requiring PHP 5.6, you must explicitly disable features incompatible with that version in your .htaccess file or php.ini, such as disabling the modern OPCache handler if it requires PHP 7 syntax.

Finally, remember that MAMP 4.1 is an older release. While this manual override works for immediate needs, relying on it creates a fragile environment where future updates to MAMP might break your custom paths. If you require long-term stability with multiple PHP versions, consider upgrading to a newer MAMP version or managing runtimes via Homebrew alongside the web server configuration, which offers more robust isolation between versions without needing to edit system scripts manually.

Our network