8

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=
Ashish Agarwal
  • 14,555
  • 31
  • 86
  • 125
  • Find out what `php.ini` file is in use `php -i` (and any other config files) and make sure the extension is enabled – Phil Sep 20 '13 at 05:57
  • what am i looking for? it outputs a lot of data – Ashish Agarwal Sep 20 '13 at 06:00
  • Try `php -i | grep '\.ini'`. Paste the results into your question – Phil Sep 20 '13 at 06:02
  • 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.ini – Ashish Agarwal Sep 20 '13 at 06:04
  • Is the extension enabled in `/etc/php.ini`? You might also want to check via a browser using a `` file. Sometimes, the CLI and web module use different `php.ini` files – Phil Sep 20 '13 at 06:06
  • Hi, I posted an answer, please have a look at it. Hope that would be helpful. – srain Sep 20 '13 at 06:20
  • @Phil, I tried phpinfo() and it gave me another path to a php.ini file. This one is in the MAMP directory that I am using. I opened this file and it does have `extension=mcrypt.so` in the file – Ashish Agarwal Sep 20 '13 at 06:29

2 Answers2

8

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
John Skoumbourdis
  • 3,041
  • 28
  • 34
srain
  • 8,944
  • 6
  • 30
  • 42
1

Updated guide as of Mac Mavericks:

http://coolestguidesontheplanet.com/install-mcrypt-php-mac-osx-10-9-mavericks-development-server/

carlosvini
  • 1,742
  • 19
  • 18