Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing mcrypt extension for PHP on OSX Mountain Lion

Apologies in advance for the potential n00b questions, I am trying to install the mcrypt extension for PHP on my OSX Mountain Lion machine.

The following steps in terminal is what I have done so far to achieve my PHP install

cd /path/to/downloaded/php-5.3.21/ext/mcrypt/ /usr/bin/phpize ./configure cd /path/to/downloaded/php-5.3.21 ./configure --with-config-file-path=/private/etc/php.ini --with-apxs2=/usr/sbin/apxs make sudo make install 

Which seems to work well and installs PHP 5.3.21 fine. I have then done

sudo nano /private/etc/php.ini 

And included

extension=mcrypt.so 

Along with an Apache restart, phpinfo() doesn't show that the mcrypt extension is loaded.

I then tried to specify the extension_dir inside php.ini, again with no luck.

I have done

locate mcrypt.so /opt/local/lib/php/extensions/no-debug-non-zts-20090626/mcrypt.so /usr/local/Cellar/php53-mcrypt/5.3.18/mcrypt.so 

And tried both directories as the extension_dir, with no luck.

I have also tried the following, after much Googling

./configure --with-config-file-path=/private/etc/php.ini --with-apxs2=/usr/sbin/apxs --with-mcrypt 

Which seems to work OK, but then upon "make", it returns

ext/mcrypt/mcrypt.o: No such file or directory ext/mcrypt/mcrypt_filter.o: No such file or directory 

Again, no success.

What am I doing wrong? It seems like the physical compile of mcrypt.so is not happening, or is compiling incorrectly as I would suspect there to be another mcrypt.so found under locate?

Anyone please help? I've gone through pages upon pages of Google searches with no luck!

like image 672
Daze Avatar asked Jan 30 '13 02:01

Daze


People also ask

What is mcrypt PHP extension required?

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 know if PHP mcrypt is installed?

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 library?

mcrypt is a replacement for the popular Unix crypt command. crypt was a file encryption tool that used an algorithm very close to the World War II Enigma cipher. Mcrypt provides the same functionality but uses several modern algorithms such as AES.


1 Answers

I tend to use Homebrew on Mac. It will install and configure all the stuff for you.
http://mxcl.github.com/homebrew/

Then you should be able to install it with brew install mcrypt php53-mcrypt and it'll Just Work (tm).

You can replace the 53 with whatever version of PHP you're using, such as php56-mcrypt or php70-mcrypt. If you're not sure, use brew search php.

Do also remember that if you are using the built in Mac PHP it's installed into /usr/bin you can see which php you are using with which php at the terminal and it'll return the path.

like image 76
David Yell Avatar answered Sep 23 '22 22:09

David Yell