Update PHP in shell and install Mcrypt

PHP

I want to update to PHP 5.6 in shell (via Terminal) before I want to install the Mcrypt extension

I followed this tutorial:

http://justinhileman.info/article/reinstalling-php-on-mac-os-x/

But when I do all of that and I type in php -v it still says PHP 5.4.24.

And when I install the Mcrypt extension with this tutorial:

http://jenssegers.be/blog/49/installing-the-php-mcrypt-extension-on-osx-10-9-mavericks
(I used PHP 5.6 instead of 5.4)

I still cannot install Laravel (that's why I'm doing this). It still gives me an error

Mcrypt PHP extension required Script php artisan clear-compiled handling the post-install-cmd event returned with an error

What can I do?

Best Answer

The easiest solution for your problem is: (I don't know you experience with the terminal so just humor me if I take you for an unexperienced user)

which php

This will give you the php binary that is used. Use your Terminal and go to that folder:

cd /path/that/whichphp/gives/you

When you punch you way to the folder do this:

  1. sudo mv php php.old <- rename the old php binary to back it up (just in case :) )

  2. sudo ln -s /path/to/the/new/php/binary php <- This will create a symlink that points to your new php binary

Easiest way to locate all your php instances and identifying the new one would be:

sudo find / -name php

After you create the symlink write php -v again into the console and you should see the version output from you new instance.

If you still have problems just contact me.

I hope this helped you : had the same problem as you once :)