Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use MAMP's version of PHP instead of the default on OSX

Tags:

php

mamp

ln

I would like to use MAMP's version of PHP instead of the default installed on my mac. I tried using

ln -s /Applications/MAMP/bin/php5.3/bin/php php

but I get a "File exists" error. What's the best way to work around this so I can just type php instead of the full path?

like image 993
Josh Fraser Avatar asked Nov 23 '10 23:11

Josh Fraser


People also ask

Where is Mamp PHP?

If you are using MAMP Standard (the Free version) then you need to open either /Applications/MAMP/bin/php/php5. 2.17/conf/php. ini or /Applications/MAMP/bin/php/php5.


1 Answers

I have created a symlink at the original php location.

1. Locate your osx php version with:

which php 

The result should be:

/opt/local/bin/php 

2. Backup (move) your original php binary:

sudo mv /opt/local/bin/php /opt/local/bin/php.bak 

3. Create the symlink:

sudo ln -s /Applications/MAMP/bin/php/php5.4.4/bin/php /opt/local/bin/php 

4. Run your new php version:

php -v 

PS:

In order for this to work on El-Capitan

  • Reboot your Mac to RecoveryMode (hold Cmd+R on boot)
  • Open Terminal and enter: csrutil disable
  • Reboot
  • either : sudo ln -s /Applications/MAMP/bin/php/php5.4.4/bin/php /opt/local/bin/php
    or sudo ln -s /Applications/MAMP/bin/php/php5.4.4/bin/php /usr/bin/php
  • Reboot again to RecoveryMode and re-enable security: csrutil enable
like image 103
Heiko K. Avatar answered Oct 21 '22 01:10

Heiko K.