Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing mcrypt with PHP on mac

Tags:

php

mcrypt

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=
like image 813
Ashish Agarwal Avatar asked Sep 20 '13 05:09

Ashish Agarwal


People also ask

How do I know if PHP mcrypt is installed?

Determine if the mcrypt extension is loaded in any of the following ways: Set up a phpinfo. php file in the web server's root directory and examine the output in a web browser. Run the following command: $ php -r "phpinfo();" | grep mcrypt.

What is PHP mcrypt package?

What is mcrypt? The mcrypt extension is a replacement for the UNIX crypt command. These commands serve as a means to encrypt files on UNIX and Linux systems. The php-mcrypt extension serves as an interface between PHP and mcrypt.

How do I enable mcrypt?

You can install Mcrypt from the PHP Source Tree as a module if you choose. Enable the module by adding: 'extension=mcrypt.so' to PHP. ini. Done!

Is mcrypt deprecated?

ext/mcrypt ¶The mcrypt extension has been abandonware for nearly a decade now, and was also fairly complex to use. It has therefore been deprecated in favour of OpenSSL, where it will be removed from the core and into PECL in PHP 7.2.


2 Answers

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
like image 199
srain Avatar answered Oct 23 '22 08:10

srain


Updated guide as of Mac Mavericks:

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

like image 24
carlosvini Avatar answered Oct 23 '22 09:10

carlosvini