Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install mcrypt on mac php7.2 MAMP

I tried following most of the tutorials here on stack overflow but got no success.

Issue in installing php7.2-mcrypt

https://github.com/tamtamnl/valet-plus/tree/hotfix/homebrew-core-php

https://github.com/weprovide/valet-plus/issues/127

https://github.com/Homebrew/homebrew-core/issues/26082

Enable MCrypt using MAMP

Laravel requires the Mcrypt PHP extension


Error 1 : Check Image Here


Here's my PHP Version on MAMP


Here's what I get when I check the version on Terminal

AVMBP:~ AV$ php -v
PHP 5.6.33 (cli) (built: Feb  1 2018 13:59:05) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.5.3, Copyright (c) 2002-2017, by Derick Rethans

when I try to install mcrypt on Terminal, here's what I get

AVsMBP:~ AV$  sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo: apt-get: command not found

I tried the following steps

brew install mcrypt

here's what I get

Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
youtube-dl

Warning: mcrypt 2.6.8 is already installed and up-to-date
To reinstall 2.6.8, run `brew reinstall mcrypt`

AVs-Macbook-Pro:~ AV$ brew reinstall mcrypt
==> Reinstalling mcrypt 
==> Downloading https://homebrew.bintray.com/bottles/mcrypt-2.6.8.yosemite.bottl
Already downloaded: /Users/AV/Library/Caches/Homebrew/mcrypt-2.6.8.yosemite.bottle.1.tar.gz
==> Pouring mcrypt-2.6.8.yosemite.bottle.1.tar.gz
🍺  /usr/local/Cellar/mcrypt/2.6.8: 18 files, 396.7KB
AVs-Macbook-Pro:~ AV$ 

then, I check if there's mcrypt installed

brew search mcrypt

here's what I get

AVs-Macbook-Pro:~ AV$ brew search mcrypt
==> Searching local taps...

mcrypt ✔                                            libtomcrypt
==> Searching taps on GitHub...
==> Searching blacklisted, migrated and deleted formulae...

After success installing mcrypt through terminal, I added mcrypt.so extension to php.ini.

/Applications/MAMP/bin/php/php7.2.1/conf/php.ini

extension=mcrypt.so

I verified if the extension was installed, and I get this ;

AVs-Macbook-Pro:~ AV$ php -i | grep "mcrypt"
Configure Command =>  './configure'  '--prefix=/usr/local/php5' '--with-apxs2=/usr/sbin/apxs' '--with-config-file-scan-dir=/usr/local/php5/php.d' '--with-libxml-dir=shared,/usr' '--with-openssl=/usr/local/php5' '--with-zlib=/usr' '--with-zlib-dir=/usr' '--with-gd' '--with-ldap' '--with-xmlrpc' '--enable-exif' '--enable-soap' '--enable-wddx' '--enable-ftp' '--with-iodbc' '--enable-sockets' '--with-bz2=/usr' '--enable-zip' '--enable-shmop' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-mbstring' '--enable-bcmath' '--enable-calendar' '--with-mhash' '--enable-fpm' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--enable-pcntl' '--enable-dtrace' '--enable-opcache' '--with-icu-dir=/usr/local/php5' '--with-mssql=shared,/usr/local/php5' '--with-pdo-dblib=shared,/usr/local/php5' '--with-xsl=shared,/usr/local/php5' '--with-imap=shared,../imap-2007f' '--with-kerberos=/usr' '--with-imap-ssl=/usr/local/php5' '--with-gettext=/usr/local/php5' '--with-curl=shared,/usr/local/php5' '--with-png-dir=/usr/local/php5' '--with-jpeg-dir=/usr/local/php5' '--enable-gd-native-ttf' '--with-freetype-dir=/usr/local/php5' '--with-pgsql=shared,/usr/local/php5' '--with-pdo-pgsql=shared,/usr/local/php5' '--with-mcrypt=shared,/usr/local/php5' '--with-tidy=/usr/local/php5' '--with-gmp=shared,/usr/local/php5' '--with-readline=shared,/usr/local/php5' '--with-libxml-dir=/usr/local/php5' 'CC=cc '-L/usr/local/php5/lib' '-I/usr/local/php5/include' '-I/usr/include/libxml2' '-I/usr/local/php5/include/tidy' '-DENTROPY_CH_RELEASE=1'' 'CFLAGS=-Os '-mmacosx-version-min=10.10' '-I/usr/local/php5/include' '-arch' '-no-cpp-precomp' '-DENTROPY_CH_ARCHS='''i386/x86_64'''' '-DENTROPY_CH_RELEASE=1'' 'LDFLAGS=-L/usr/local/php5/lib '-arch' 'CXXFLAGS=-arch
/usr/local/php5/php.d/50-extension-mcrypt.ini,
Registered Stream Filters => zlib.*, bzip2.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, mcrypt.*, mdecrypt.*, http.*
mcrypt
mcrypt support => enabled
mcrypt_filter support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value
AVs-Macbook-Pro:~ AV$ 

Restarted the system and, I still get this error when I run my php system

An Error Was Encountered
The Encrypt library requires the Mcrypt extension.

Please help me. Thanks in advance!

like image 511
avlz Avatar asked Sep 19 '26 10:09

avlz


1 Answers

If you don't have the mcrypt library installed correctly then try below:

https://gist.github.com/idleberg/24479f34dc5007e50d47

Or See http://www.php.net/manual/en/mcrypt.setup.php for other information.

If you are on shared hosting, you can ask your provider to install it.


In OSX localhost you can easily install mcrypt via homebrew - as you have tried above:

brew install mcrypt

Then add this line to your php.ini file. You can see from the homebrew output above: "/usr/local/Cellar/mcrypt/2.6.8"

extension="/usr/local/Cellar/mcrypt/2.6.8/mcrypt.so"

Don't forget to restart server for edits to take effect

like image 143
Jason Avatar answered Sep 22 '26 16:09

Jason



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!