Last Updated: February 25, 2016
·
2.123K
· timfernihough

SOLVED: MAMP won't use the right PHP binary. What's wrong?

I recently wrote an article on how to resolve the common mySQL/Unix error message Can't connect to local mySQL server through socket /tmp/mysql.sock obtained when trying to use MAMP mySQL and for some reason OSX tries to use the native mySQL socket.

I recalled I had a similar problem where the operating system was expecting PHP to be located in /usr/bin/php but my PHP binary from MAMP was located in /Applications/MAMP/bin/php/php5.2.17/bin/php

Here would be the steps to locate the binary that your OS is using so that you can create a symlink in the same fashion:

whereis php

If the location is /usr/bin/php, you can then do the following:

sudo ln -s /Applications/MAMP/bin/php/php5.2.17/bin/php /usr/bin/php

This effectively tells the OS to redirect to the binary associated with your MAMP (and therefore, use the php.ini you care about, rather than the php.ini file that native OSX ships with).