Add php version to mamp

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!

If you're working on a project that requires a version of PHP higher than the versions that MAMP comes with, you can easily add additional verions.

My version of MAMP came installed with PHP 7.4.21 and 8.0.8. I'm attempting to use MAMP to host a Laravel application which requires at least PHP 8.1.

The version of PHP MAMP uses is often different than the version you have installed. I have installed PHP using Brew. I'm currently running PHP 8.1.8. If you want to check your installed version of PHP, use the terminal and run the following command:

php --version

Add php version to mamp

  1. First we need to copy the installed PHP files to MAMP. Using Finder, navigate to /usr/local/Cellar/php and you should find a folder named after the installed version of PHP. For me it was 8.1.8. Copy this folder.

  2. Navigate to the folder that MAMP stores PHP versions. For me this was /Applications/MAMP/bin/php. Paste this folder here.

  3. Rename this folder to php8.1.8 (use your PHP version number).

  4. Next we need the PHP modile file. Navigate to /usr/local/lib/httpd and copy the modules folder. Inside this folder is the PHP module file names libphp.so.

  5. Navigate to /Applications/MAMP/bin/php/php8.1.8 and paste the modules folder.

  6. Close and restart MAMP.

  7. Choose PHP 8.1.8 from the frop down and you should be good to go!

Add php version to mamp

I have a video walk-through on YouTube!

Languages > PHP

PHP is a popular web scripting programming language. MAMP PRO installs several versions of the PHP script interpreter.

Add php version to mamp


  • Default version
    Select which PHP version will be the default version.

    • Plus
      A click on this button opens a dialog box with a list of the additional available PHP versions. By clicking on the “Install” button of the required PHP version this version will be added to your development environment. Afterwards a restart of MAMP PRO is necessary.

      Add php version to mamp

      Adding Additional PHP Versions

    • Minus
      A click on this button will delete the selected PHP version from your development environment. You have to confirm this before.

      Add php version to mamp

      MAMP PRO requires PHP 5.4.45 internally for the installation of the extras. This version can therefore not be removed and the minus button is deactivated for this PHP version.

    • Open template…
      A click on this button opens the internally used template file for the php.ini file in an editor window. More information about this template file can be found here.

    • Activate command line shortcuts for the selected PHP version, pear & pecl
      Check this option to make the current PHP version available on the command line. This allows you to install additional PHP extensions via PECL, for example. MAMP PRO uses aliases to provide this functionality. When this option is checked the following is added to your “~/.profile” file.

      alias php='/Applications/MAMP/bin/php/phpx.x.x/bin/php -c "/Library/Application Support/appsolute/MAMP PRO/conf/phpx.x.x.ini"'
      alias pear='/Applications/MAMP/bin/php/phpx.x.x/bin/pear'
      alias pecl='/Applications/MAMP/bin/php/phpx.x.x/bin/pecl'
      

      After the default PHP version is changed when this option has been selected, this command should be run in a new Terminal window to refresh the settings to reflect the changes:

      Confirm your PHP is enabled by typing php -v in a new Terminal window.

      Add php version to mamp

      • Also activate shortcut for Composer
        When this option is checked the following is added to your “~/.profile” file.

        alias composer='/Applications/MAMP/bin/php/composer'
        


  • Mode
    Choose whether to use identical PHP versions for all hosts (Module) or on a host by host basis (CGI).

    • Module (all hosts use the same PHP version)
      Select this option to run PHP in module mode. All your hosts will use the same version of PHP.

    • CGI (every host may be set to a different PHP version)
      Select this option to run PHP in CGI mode. This allows you to specify which version of PHP to use for each of your hosts separately.

      More information on how to change the PHP version for an individual host is covered in the Settings > Hosts > General section.


  • Cache module to speed up execution
    PHP has several cache extensions that can help speed up execution in certain circumstances. This is set to “off” by default. Enabling a cache extension does not necessarily translate into greater execution speed. A particular cache is not available for the current PHP version if it is not enabled.

    Several caches provide a user interface to help analyze and profile your code. Press the arrow button to the right of the cache name to view this interface. An interface is not available if the arrow button is not enabled.

    • off
      Select this option if no PHP cache module should be used.

    • APC
      The Alternative PHP Cache (APC) is a free and open opcode cache for PHP. You can learn more about APC here.

    • eAccelerator
      eAccelerator a free open-source PHP accelerator & optimizer. This cache is available for the following PHP versions: 5.3 & 5.4. You can learn more about eAccelerator here.

    • XCache
      XCache is a open-source opcode cacher. This cache is available for the following PHP versions: 5.3 to 5.6. You can learn more about XCache here.

    • OPCache
      OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request. You can learn more about OPcache here.


  • Extensions

    • Xdebug (Debugger)
      Activate Xdebug to allow PHP to create debugging information during script execution. By default, Xdebug uses localhost and port 9000 in the php.ini file. More information on using Xdebug with the MacGDBp Debugger can be founder here.

      • Download MacGDBp…
        Clicking this button opens the MacGDBp website in your default browser.

      • Open MacGDBp
        With Xdebug activated you can open the MacGDBp debugger to enable PHP debugging. By default, MacGDBp expects debugging information on port 9000 of localhost. More information on using Xdebug with the MacGDBp Debugger can be founder here.

    • Imagick / ImageMagick
      If you activate this checkbox, then Imagick resp. ImageMagick is available.

    • Tidy
      If you activate this checkbox, then Tidy is available.

    • Oauth
      If you activate this checkbox, then Oauth is available.

    • Enable other extensions…
      A click on this button opens the internally used template file for the php.ini file in an editor window. More information about this template file can be found here.


  • What to log
    Here you define the type of messages to be reported.

    • Display startup errors
      Log PHP errors that occur when Apache loads the PHP module.

    • All other errors and warnings (E_ALL)
      If you activate this checkbox, all errors and warnings are reported. This option corresponds to the setting E_ALL. See the PHP documentation in the “error_reporting” section for more information.

    • Errors (E_ERROR)
      If you activate this checkbox, all errors are reported. This option corresponds to the setting E_ERROR. See the PHP documentation in the “error_reporting” section for more information.

    • Warnings (E_WARNING)
      If you activate this checkbox, all warnings are reported. This option corresponds to the setting E_WARNING. See the PHP documentation in the “error_reporting” section for more information.

    • Notices (E_NOTICE)
      If you activate this checkbox, all notices are reported. This option corresponds to the setting E_NOTICE. See the PHP documentation in the “error_reporting” section for more information.

    • Other
      Report further error types through constants. Please turn to the PHP documentation for further information.


  • Log errors
    Here you can choose where the messages should be written to.

    • to screen
      Activate this checkbox if you want the messages to be displayed on your website.

    • to file
      Activate this checkbox if the messages are to be written to a file.

      • Choose…
        Here you can choose the directory and the file name. By default, the message is written to the file “/Applications/MAMP PRO/logs/php_error.log”.

Can I change PHP version in MAMP?

Fortunately you can force MAMP to allow you to select the versions of PHP that you want to use with a few directory renames! The trick is to rename whichever version of PHP you do not wish to use by putting an underscore (_) character in front of the original directory name.

How do I change the default PHP version in MAMP?

Go to File > Edit > Edit Template > PHP (php..
Find max_execution_time and set it to 60 or higher..
Find memory_limit and set it to 256M or higher..
Save and close the file..
Restart MAMP..

Where is PHP installed on MAMP?

If you are using MAMP Standard (the Free version) then you need to open either /Applications/MAMP/bin/php/php5. 2.17/conf/php.

Does MAMP have PHP?

PHP is a popular web scripting programming language. MAMP PRO installs several versions of the PHP script interpreter. button. Note: To remove unneeded PHP versions simply stop your servers, quit MAMP PRO, and remove your /Applications/MAMP/bin/php/phpX.