Reputation: 8714
I am using OSX El Capitan and I see that /usr/bin/php is using wrong php version.
which php
/usr/bin/php
php -v
PHP 5.5.34 (cli) (built: Apr 22 2016 19:16:58)
I have installed latest MAMP and I tried to create a symlink to the correct version
sudo ln -sf /Applications/MAMP/bin/php/php7.0.9/bin/php /usr/bin/php
Password:
ln: /usr/bin/php: Operation not permitted
Can anyone suggest how can I fix this?
Upvotes: 1
Views: 4761
Reputation: 9979
Your real problem is Mac SIP (System Integrity Protection). When SIP is enabled you can't write anything to /usr (with the exception of /usr/local). Disable it and make the symlink. Make sure to re enable SIP after symlink creation.
To disable SIP
1)Reboot the Mac and hold down Command + R keys simultaneously after you hear the startup chime, this will boot OS X into Recovery Mode.
2)When the “OS X Utilities” screen appears, pull down the ‘Utilities’ menu at the top of the screen instead, and choose “Terminal”
3)Type the following command into the terminal then hit return:
csrutil disable; reboot
Upvotes: 0
Reputation: 8714
I solved it using different approach then disabling SIP
sudo nano ~/.bash_profile
I have added
alias php="/usr/local/bin/php"
Then I added a symlink
sudo ln -sf /Applications/MAMP/bin/php/php7.0.9/bin/php /usr/bin/php
And then I checked php version
php --version
And it showed 7.0.9 as expected
Upvotes: 5