Installing mcrypt with PHP on mac

Ashish Agarwal picture Ashish Agarwal · Sep 20, 2013 · Viewed 17.2k times · Source

I am trying to install the mcrypt extension for PHP on my mac.

I used the homebrew command to install it

 brew install php53-mcrypt

This gives me a message saying that it is already installed: php53-mcrypt-5.3.26 already installed

However, when I run the command php -m, I do not see mcrypt in the list (I have restarted the terminal).

Edit 1: Adding mcrypt section of php.ini.default

In the php.ini.default file, this is section I have regarding mcrypt

[mcrypt]
; For more information about mcrypt settings see http://php.net/mcrypt-module-open

; Directory where to load mcrypt algorithms
; Default: Compiled in into libmcrypt (usually /usr/local/lib/libmcrypt)
;mcrypt.algorithms_dir=

; Directory where to load mcrypt modes
; Default: Compiled in into libmcrypt (usually /usr/local/lib/libmcrypt)
;mcrypt.modes_dir=

Answer

srain picture srain · Sep 20, 2013

Fisrt, find out where is the php.ini:

php -i | grep php.ini

Then you will see something like these:

Configuration File (php.ini) Path => /usr/local/php/etc
Loaded Configuration File => /usr/local/etc/php54/php.ini

Open the Configuration File:

vim /usr/local/etc/php54/php.ini

search this file and check if you have something like this:

extension=mcrypt.so

copy mcrypt.so to extension_dir which is indicated also in php.ini.

or set mcrypt.modes_dir

mcrypt.modes_dir=/usr/lib/libmcrypt.so