It’s very often that you want to change the PHP version in order to install different softwares in your development environment. But the MAMP version in your system comes with pre-installed version of PHP, and you want to go with it.
But this tutorial is explaining how to change php version in MAMP. Follow the steps.
- Open this file in your favourite text editor
/Applications/MAMP/conf/apache/httpd.conf
Search for and comment the followiing line – LoadModule php7_module.
It could be LoadModule php5_module, depending on your version. - 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 thehttpd.conf
fileInclude /Applications/MAMP/conf/apache/extra/httpd-php-extra.conf
- Create a file called
httpd-php-extra.conf
in the in the extra folder as we declared in the previous file. And add the below configurations to the fileLoadModule php7_module /Applications/MAMP/bin/php/php7.3.9/modules/libphp7.so
You can get available PHP versions in this folder –
/Applications/MAMP/bin/php
It’s not finished yet, next we can check how to change the PHP version when accessing via CLI in MAMP.
- Next, change the PHP version in Cli in MAMP
Open your Terminal / Commandline and type insudo nano ~/.bashrc
- Add the following line (change the path as needed):
alias php="/Applications/MAMP/bin/php/php7.3.9/bin/php"
- Save the fille
- Run the below command
source ~/.bashrc
- All set, test it out
Hope you’ve enjoyed the tutorial, let others know as well.
Did this post help you?
Tutsplanet brings in-depth and easy tutorials to understand even for beginners. This takes a considerable amount of work. If this post helps you, please consider supporting us as a token of appreciation:
- Just want to thank us? Buy us a Coffee
- May be another day? Shop on Amazon using our links.
Your prices won't change but we get a small commission.
Leave a Reply