Skip to content

Instantly share code, notes, and snippets.

@codeadamca
Last active April 30, 2024 13:32
Show Gist options
  • Star 28 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save codeadamca/09efb674f54172cbee887f04f700fe7c to your computer and use it in GitHub Desktop.
Save codeadamca/09efb674f54172cbee887f04f700fe7c to your computer and use it in GitHub Desktop.
How to add new PHP versions to MAMP on a Mac

Adding Versions of PHP to MAMP on a Mac

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

terminal-php-version

  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!

mamp-php-8 1 8

I have a video walk-through on YouTube!

@Franky5831
Copy link

hey, i don't have a "Cellar" folder inside my local folder

@codeadamca
Copy link
Author

codeadamca commented Oct 3, 2022

Just a few notes that might help... This only works if you have PHP installed. Type php -v in the Terminal to confirm its installed. If it is installed, the folder may be different on each system. You may have to do some looking around.

Copy link

ghost commented Oct 11, 2022

works great ! I've just use symbolic links instead of copy. Thanks 🙏

@profexpress
Copy link

profexpress commented Oct 21, 2022

I followed your tutorial step by step and could get the "PHP 8.1.x" option in the "PHP version" dropdown list of MAMP. But when starting MAMP I get a modal error saying "Apache couldn't be started. Please check your MAMP installation and configuration."
And it returns the same error when trying to start it with PHP 8.0.8!

@codeadamca
Copy link
Author

If you're having trouble getting this solution to work, I'm not sure how much help I can be, it might be different based on your device configuration. However, I would highly recommend Docker! It's a much better solution than using MAMP.

@analivko
Copy link

I followed your tutorial step by step and could get the "PHP 8.1.x" option in the "PHP version" dropdown list of MAMP. But when starting MAMP I get a modal error saying "Apache couldn't be started. Please check your MAMP installation and configuration."
And it returns the same error when trying to start it with PHP 8.0.8!

It is because in modules folder has shortcuts NOT files. Right click on file and go to original. Copy this files to your module folder. libphp.so - this file in one folder and other files in another folder. Then restart mamp.

@l-o-u-k-e
Copy link

It is because in modules folder has shortcuts NOT files. Right click on file and go to original. Copy this files to your module folder. libphp.so - this file in one folder and other files in another folder. Then restart mamp.

@analivko unfortunately I had the same behavior reported by @profexpress but my libphp.so in module folder is a file not a shortcut. Any ideas? Thanks

@helemaaldebom
Copy link

Also didn't work for me. Would love a solution for this. Thanks!

@radrr
Copy link

radrr commented Dec 7, 2022

For me it works, i just took the "modules" folder with PHP module for Apache from /usr/local/Cellar/php@7.4/7.4.33/lib/httpd/modules folder. As you have probably noticed, I'm using PHP 7.4.33, adapt the path to you PHP version.

@LoesGrim
Copy link

LoesGrim commented Dec 9, 2022

hey, i don't have a "Cellar" folder inside my local folder

If you have a macbook M1 the folder will be inside opt/homebrew/Cellar ...
I have also found the modules folder inside op/homebrew/lib/httpd/modules

@ivke013
Copy link

ivke013 commented Dec 16, 2022

Thanks alot! This save my time

@ramilzv
Copy link

ramilzv commented Dec 19, 2022

Thanks alot! This save my time

Did you get the version over 8.1 working? I keep getting an Apache error on mac m1, analogues like xampp don't work either

@jzohrab
Copy link

jzohrab commented Dec 27, 2022

Thank you @analivko for the tip re the shortcut, that solved my initial setup problem.

For future visitors to this helpful gist, it sometimes helps to run sudo /Applications/MAMP/Library/bin/apachectl start from terminal, because that at least gives some hints as to where possible problems might be coming from. MAMP doesn't always log details for this error, but the terminal command shows where your .conf file is bad, for example.

@maplesyrupweb
Copy link

Thanks for writing the article and making the video. It's the best video for changing the version of PHP in MAMP.

I followed step by step and can see in phpmyinfo of MAMP that 8.2.1 of PHP is installed and running, but in the MAMP UI dropdown, it doesn't show the new version. Also, phpmyadmin stopped working after changing to the new PHP version.

I download MAMP version 6.7 which has PHP 8.2.0 installed. In the future, I will consider using Docker for PHP.

@Gas9220
Copy link

Gas9220 commented Apr 28, 2023

Thank you!

@mnadee123
Copy link

apache server is working but mysql server isn't.

@namih
Copy link

namih commented May 23, 2023

Apache couldn't be started. Please check your MAMP installation and configuration.

I followed your tutorial step by step and could get the "PHP 8.1.x" option in the "PHP version" dropdown list of MAMP. But when starting MAMP I get a modal error saying "Apache couldn't be started. Please check your MAMP installation and configuration."
And it returns the same error when trying to start it with PHP 8.0.8!

It is because in modules folder has shortcuts NOT files. Right click on file and go to original. Copy this files to your module folder. libphp.so - this file in one folder and other files in another folder. Then restart mamp.

thanks. it worked for me

@mukaspc
Copy link

mukaspc commented Jun 15, 2023

Useful info, all is clear, all working. Thanks!
(PHP 8.1.15)

@vitalijalbu
Copy link

vitalijalbu commented Jul 11, 2023

Hi guys, I laso have problem with phpmyadmin. I want to update it to latest, because i moved to php 8.2 but phpmyadmin has some bugs...
anyone can help? Thanks.

Screenshot 2023-07-11 alle 09 54 00

@Aleksandr0114
Copy link

Aleksandr0114 commented Aug 24, 2023

Hi. I installed everything according to the instructions, but the Apache in MAMP doesn't want to run. I started apachectl and got errors such as: httpd: Syntax error on line 160 of /Applications/MAMP/conf/apache/httpd.conf: Cannot load /Applications/MAMP/bin/php/php8.2.9/modules/libphp.so into server: dlopen(/Applications/MAMP/bin/php/php8.2.9/modules/libphp.so, 0x000A): Library not loaded: @loader_path/../../../../../../opt/tidy-html5/lib/libtidy.58.dylib\n

I opened the libphp.so file and there are ways to library via @loader_path/.. /.. /.. /.. /.. /.. /opt/lib and it will not work from path /Applications/MAMP/bin/php/php8.2.9/

Could you give me some advice?

nevermind. I changed line in /Applications/MAMP/conf/apache/httpd.conf
to LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so
and run mamp via command line

@dakenn
Copy link

dakenn commented Sep 4, 2023

Hi. I installed everything according to the instructions, but the Apache in MAMP doesn't want to run. I started apachectl and got errors such as: httpd: Syntax error on line 160 of /Applications/MAMP/conf/apache/httpd.conf: Cannot load /Applications/MAMP/bin/php/php8.2.9/modules/libphp.so into server: dlopen(/Applications/MAMP/bin/php/php8.2.9/modules/libphp.so, 0x000A): Library not loaded: @loader_path/../../../../../../opt/tidy-html5/lib/libtidy.58.dylib\n

I opened the libphp.so file and there are ways to library via @loader_path/.. /.. /.. /.. /.. /.. /opt/lib and it will not work from path /Applications/MAMP/bin/php/php8.2.9/

Could you give me some advice?

nevermind. I changed line in /Applications/MAMP/conf/apache/httpd.conf to LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so and run mamp via command line

Hi Aleksandr0114, I had the same problem. My solution was:
cd /Applications/MAMP/bin/php
ln -s /opt/homebrew/opt/php@8.1/ php8.1.23
ln -s /opt/homebrew/opt/php@8.1/lib/httpd/modules modules

I hope this helps you.

@volkov989
Copy link

Hi. I installed everything according to the instructions, but the Apache in MAMP doesn't want to run. I started apachectl and got errors such as: httpd: Syntax error on line 160 of /Applications/MAMP/conf/apache/httpd.conf: Cannot load /Applications/MAMP/bin/php/php8.2.9/modules/libphp.so into server: dlopen(/Applications/MAMP/bin/php/php8.2.9/modules/libphp.so, 0x000A): Library not loaded: @loader_path/../../../../../../opt/tidy-html5/lib/libtidy.58.dylib\n
I opened the libphp.so file and there are ways to library via @loader_path/.. /.. /.. /.. /.. /.. /opt/lib and it will not work from path /Applications/MAMP/bin/php/php8.2.9/
Could you give me some advice?
nevermind. I changed line in /Applications/MAMP/conf/apache/httpd.conf to LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so and run mamp via command line

Hi Aleksandr0114, I had the same problem. My solution was: cd /Applications/MAMP/bin/php ln -s /opt/homebrew/opt/php@8.1/ php8.1.23 ln -s /opt/homebrew/opt/php@8.1/lib/httpd/modules modules

I hope this helps you.

Thank you so much!!!

@tonweb-ru
Copy link

Hi. I installed everything according to the instructions, but the Apache in MAMP doesn't want to run. I started apachectl and got errors such as: httpd: Syntax error on line 160 of /Applications/MAMP/conf/apache/httpd.conf: Cannot load /Applications/MAMP/bin/php/php8.2.9/modules/libphp.so into server: dlopen(/Applications/MAMP/bin/php/php8.2.9/modules/libphp.so, 0x000A): Library not loaded: @loader_path/../../../../../../opt/tidy-html5/lib/libtidy.58.dylib\n
I opened the libphp.so file and there are ways to library via @loader_path/.. /.. /.. /.. /.. /.. /opt/lib and it will not work from path /Applications/MAMP/bin/php/php8.2.9/
Could you give me some advice?
nevermind. I changed line in /Applications/MAMP/conf/apache/httpd.conf to LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so and run mamp via command line

Hi Aleksandr0114, I had the same problem. My solution was: cd /Applications/MAMP/bin/php ln -s /opt/homebrew/opt/php@8.1/ php8.1.23 ln -s /opt/homebrew/opt/php@8.1/lib/httpd/modules modules

I hope this helps you.

I linked the specified directories, but the required version did not appear in the MAMP interface. I also copied the conf folder inside the php8.1 folder, which for some reason was not in /opt/homebrew/Cellar/php@8.1/8.1.24 . Can you tell me by what criterion the program searches for versions in a folder /Applications/MAMP/bin/php (presence of a config, a specific folder or file)?

@LisaDawson
Copy link

LisaDawson commented Nov 9, 2023

I opted to install PHP 8.1.8 using Brew, ensuring compatibility. It's crucial to verify your installed PHP version, especially when MAMP may use a different one.

@jaypee-erni
Copy link

jaypee-erni commented Feb 6, 2024

hey, i don't have a "Cellar" folder inside my local folder

mine is located in /opt/homebrew/Cellar/

BTW. The way I did it is very simple, no need to do some jargons. Basically in MAMP only 2 php version are being shown in the UI.
Now you just need to go to Applications/mamp/bin/php and remove / rename all php folder version that you will not use. example php5.4.4.5 to 5.4.4.5xxxx. Just make sure not to touch 2 folder that you need. Then restart the mamp then VOALA!

@tkud04
Copy link

tkud04 commented Apr 4, 2024

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment