Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Instructions on how to change preinstalled Mac OS X PHP to MAMP's PHP Installation and then install Composer Package Management

Change default Mac OS X PHP to MAMP's PHP Installation and Install Composer Package Management

Instructions to Change PHP Installation

First, Lets find out what version of PHP we're running (To find out if it's the default version).

To do that, Within the terminal, Fire this command:

which php

This should output the path to the default PHP install which comes preinstalled by Mac OS X, 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 /Applications/MAMP/bin/php/php5.4.10/bin (MAMP 2.1.3)

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

Follow these simple steps:

  1. Within the Terminal, run vim ~/.bash_profile

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

     export PATH=/Applications/MAMP/bin/php/php5.4.10/bin:$PATH
  3. Hit ESC, Type :wq, and hit Enter

  4. In Terminal, run source ~/.bash_profile

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

  6. In case it doesn't output the correct path, try closing the terminal window (exit fully) and open again, it should apply the changes (Restart in short).

Install Composer Package Management

Now you can fire the command to install the composer globally (So you can access it from anywhere):

$ curl -sS | php -- --install-dir=/usr/local/bin --filename=composer

You can verify your installation worked by typing the following command within the Terminal:


It'll show you the current version and a list of commands you can use if the installation was successful.

Copy link

Years down the line, and this just saved me a whole lot of "googling". Thanks a lot

Copy link

It worked perfectly. Thank you!

Copy link

Phongveth commented Jul 29, 2018

Thank your very much @Narayanareddy96 , Worked for me , when to did follwing those steps

Copy link

pimkle commented Aug 7, 2018

Thank you so much!

Copy link

Thank you so much.... very very helpful

Copy link

Thanks for this. It worked for me.

Copy link

Worked for me, thanks a lot!

Copy link

super! thanks a lot!

Copy link

I had a similar issue, turns out the order in which I was setting the PATH var was the problem:
export PATH="/usr/local/php5/bin:/usr/bin:$PATH"

not ok:
export PATH="/usr/bin:/usr/local/php5/bin:$PATH"
I had a php bin in both folders...

So make sure that the folder with the correct php version is placed first in the PATH variable

That was it. Thanks!

Copy link

:) thanks

Copy link

Thanks, this helped so much.

Copy link

Luismij commented Oct 5, 2019

Thank you this helped me so much

Copy link

zhe1ka commented Nov 18, 2019


Copy link

saulojmc commented Apr 1, 2020

thanks my friend

Copy link

Rizzeol commented May 24, 2020

very helpful. solved after 2 days of struggle. many thanks.

Copy link

@JonWalkerTN are you using oh-my-zsh by any chance? That's what I'm using, and instead of editing ~/.bash_profile, edit your ~/.zshrc instead, and add the exact same lines. Then run source ~/.zshrc. That solved the issue for me.

many weeks of struggle. Thanks

Copy link

@JonWalkerTN are you using oh-my-zsh by any chance? That's what I'm using, and instead of editing ~/.bash_profile, edit your ~/.zshrc instead, and add the exact same lines. Then run source ~/.zshrc. That solved the issue for me.

@zhiachong Thank you so much :-) It felt like a big achievement to change that link hahaha. Had a good laugh when t finally worked after trying for quite some time.

Copy link

terimakasih banyak / thank you so much.... finally solved during this week

Copy link

marielLatellaBarros commented Nov 22, 2020

THANK YOU so much! I've been struggling with this for YEARS :0)

Copy link

brew install composer - after installing - is also working nowadays.

Copy link

thx. big help

Copy link

awesome-urch commented Apr 22, 2021

Thank you!

After running
echo $PATH
I get this:
Is it okay?

Because I still get
after running
which php

Please help me

Copy link

Hello guys,
Can someone here tell me how to make my Mac stop pointing to MAMP composer and php. Have uninstalled MAMP and added the default php and composer to path but every time I do composer something..... or php something..... I get an error -bash: /Applications/MAMP/bin/php/composer: No such file or directory yet when I do which composer, I get /usr/local/bin/composer. Thanks in advance......

Copy link

You save my day!

Copy link

Ayman1970 commented Jan 15, 2022

After several tries, I still get /usr/bin/php like other here, and my php ver is running on MAMP is 7.4.21 ver and also I could run 8.0.8 ver.
but when I run composer installing command, it gives me this message:
-bash: /Applications/MAMP/bin/php/php7.4.16/bin/php: No such file or directory
how to solve this problem, please.

Copy link

After 2 days of hell, you just saved me. Thanks a lot

Copy link

litsazib commented Oct 3, 2022 via email

Copy link

kingozorg commented Oct 3, 2022 via email

Copy link

psikom commented Dec 4, 2022

It worked perfectly. Thank you

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