Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing mcrypt on OSX 10.8.2 - PHP 5.3.15 with homebrew

Tags:

php

mcrypt

I've successfully installed mcrypt via homebrew but I'm struggling to find the path to mcrypt.so to include it as an extension in php.ini.

mcrypt was installed at /usr/local/Cellar/mcrypt/2.5.8. Tree:

-- AUTHORS
|-- ChangeLog
|-- INSTALL_RECEIPT.json
|-- NEWS
|-- README
|-- TODO
|-- bin
|   `-- libmcrypt-config
|-- include
|   |-- mcrypt.h
|   `-- mutils
|       `-- mcrypt.h
|-- lib
|   |-- libmcrypt.4.4.8.dylib
|   |-- libmcrypt.4.dylib -> libmcrypt.4.4.8.dylib
|   `-- libmcrypt.dylib -> libmcrypt.4.4.8.dylib
`-- share
    |-- aclocal
    |   `-- libmcrypt.m4
    `-- man
        `-- man3
            `-- mcrypt.3

I tried to include mcrypt.h in php.ini:

extension="/usr/local/Cellar/mcrypt/2.5.8/include/mcrypt.h"

and then restarted apache. but it didn't work.

when I run php in the terminal I get:

PHP Warning:  PHP Startup: Unable to load dynamic library
'/usr/local/Cellar/mcrypt/2.5.8/include/mcrypt.h' - dlopen(/usr/local/Cellar/mcrypt/2.5.8/include/mcrypt.h, 9): 
image not found in Unknown on line 0
like image 518
Matanya Avatar asked Jan 16 '13 11:01

Matanya


People also ask

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!

How do I know if mcrypt is enabled?

You can also achieve this same screen by viewing a php file that has: phpinfo(); somewhere in the code. In this screen, simply search for the string "mcrypt support". If installed, you will see a box that says "enabled".

What is mcrypt extension?

The mcrypt extension is an interface to the mcrypt cryptography library. This extension is useful for allowing PHP code using mcrypt to run on PHP 7.2+. The mcrypt extension is included in PHP 5.4 through PHP 7.1.


2 Answers

First check if brew is up-to-date:
brew doctor

Second install mcrypt based on php version:
brew install php53-mcrypt

NB: Step three below is not required on recent versions of brew:

Third open php.ini file and add reference:
sudo vi /private/etc/php.ini
extension="/usr/local/Cellar/php53-mcrypt/5.3.25/mcrypt.so"

Finally, restart apache:
sudo apachectl restart

like image 88
pinxi Avatar answered Nov 15 '22 23:11

pinxi


After wondering for hours through different advices, this one worked for me (Installed via MacPorts):

Courtesy of Chris Brewer:

Download and install MacPorts from http://macports.org.

The following steps are performed in the Terminal:

Force MacPorts to update (will only work if Apple's Xcode installed):

sudo port -v selfupdate

Now, install memcached:

sudo port install php5-mcrypt

Copy the newly created shared object for mcrypt into Mac OS X’s default PHP5 extension directory:

sudo cp /opt/local/lib/php/extensions/no-debug-non-zts-20090626/mcrypt.so /usr/lib/php/extensions/no-debug-non-zts-20090626/

Next, you need to edit php.ini to add the extensions. Find the phrase Dynamic Extensions, and add:

extension=mcrypt.so

And finally, restart Apache:

sudo apachectl restart

like image 45
Matanya Avatar answered Nov 16 '22 01:11

Matanya