How To Change Pre-Installed PHP Version To MAMP In Mac/osx

If you are using Mac OSX for the first time and switched from the windows environment and want to develop some cool web-based application then you need to install MAMP which is absolutely free. After installing MAMP on your local environment you need to add the MAMP version of PHP to the PATH variable.

Instructions to Change PHP Installation:

First, Let’s find out what version of PHP we’re running (To find out if it’s the default version). To do that, within the terminal, run this command:

which php

This should output the path to the default PHP install which comes pre-installed by Mac OSX, by default it has to be (Assuming you’ve not changed it before):


Now, we just need to swap this over to the PHP that is installed with MAMP, which is located at


To do this, we need to edit the .bash_profile and add the MAMP version of PHP to the PATH variable.

Within the Terminal, run

vim ~/.bash_profile

Type i and then paste the following at the top of the file:

export PATH=/Applications/MAMP/bin/php/php7.1.6/bin:$PATH

Hit esc, Type :wq, and hit enter.

In Terminal, run

source ~/.bash_profile

Now type in which php again and look for the updated string. If everything was successful, It should output the new path to the MAMP PHP install.

Happy Coding 😉