8
votes

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=
2
Find out what php.ini file is in use php -i (and any other config files) and make sure the extension is enabledPhil
what am i looking for? it outputs a lot of dataAshish Agarwal
Try php -i | grep '\.ini'. Paste the results into your questionPhil
This is what I got Configuration File (php.ini) Path => /etc Scan this dir for additional .ini files => (none) Additional .ini files parsed => (none) user_ini.filename => .user.ini => .user.iniAshish Agarwal
Is the extension enabled in /etc/php.ini? You might also want to check via a browser using a <?php phpinfo() ?> file. Sometimes, the CLI and web module use different php.ini filesPhil

2 Answers

8
votes

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