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
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.conffile, you’ll see where additional configurations are loaded from the extra folder. Add this to the bottom of the
- Create a file called
httpd-php-extra.confin the in the extra folder as we declared in the previous file. And add the below configurations to the file
LoadModule php7_module /Applications/MAMP/bin/php/php7.3.9/modules/libphp7.so
You can get available PHP versions in this folder –
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 in
sudo nano ~/.bashrc
- Add the following line (change the path as needed):
- Save the fille
- Run the below command
- All set, test it out
Hope you’ve enjoyed the tutorial, let others know as well.
Leave a Reply