Cài php 71 mcrypt cho mac

Setup php-mcrypt on macOS (and versions of Mac OS X)

These steps should have been mentioned in the prerequisites of the Laravel Installation Guide, since I'm surely not the only person trying to get Laravel running on macOS.

Install Mcrypt using Homebrew and PECL (comes with PHP)

# PHP 7.3
$ brew install mcrypt
$ pecl install mcrypt-1.0.3

Find your php.ini:

$ php -i | grep "Loaded Configuration File"
Loaded Configuration File => /usr/local/etc/php/7.3/php.ini

Add this line to your php.ini:

extension=/usr/local/Cellar/php/7.3.x/pecl/20180731/mcrypt.so

Historic Answer

Install Mcrypt using Homebrew

# PHP 7
$ brew install php70-mcrypt

# PHP 5
$ brew install php56-mcrypt --without-homebrew-php

Add this line to /private/etc/php.ini:

# PHP 7
extension="/usr/local/Cellar/php70-mcrypt/7.0.x/mcrypt.so"

# PHP 5
extension="/usr/local/Cellar/php56-mcrypt/5.6.x/mcrypt.so"

You are ready to go!

Upgrade

Upgrade Mcrypt using Homebrew

$ brew reinstall -fs php71-mcrypt

On macOS High Sierra I did this steps:

1- Search the package:

brew search mcrypt

Result:

==> Searching local taps... homebrew/php/php71-mcrypt mcrypt homebrew/php/php53-mcrypt
homebrew/php/php54-mcrypt homebrew/php/php55-mcrypt homebrew/php/php56-mcrypt homebrew/php/php70-mcrypt libtomcrypt

2- Search my php version to know what can I need to install:

php --version

Result:

PHP 7.1.7 (cli) (built: Jul 15 2017 18:08:09) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

3- Install the correct package, for me was 7.1.7 => homebrew/php/php71-mcrypt

brew install homebrew/php/php71-mcrypt

4- Find the find "mcrypt.so" extension file

find /usr/ -type f -name "mcrypt.so"

Result:

find: /usr//local/Cellar/php71-mcrypt/7.1.13_19/mcrypt.so

5- Search the php.ini

php -i | grep 'Configuration File'

Result (if exist):

Configuration File (php.ini) Path => /etc Loaded Configuration File => /etc/php.ini

6- Add the next line at the end on /etc/php.ini (see the last step your correct path) the extension mcrypt.so

 extension=/usr/local/Cellar/php71-mcrypt/7.1.13_19/mcrypt.so

Finish, you can now execute your command.

Sorry, I had missed that. What I was looking at was this part: sudo /usr/local/opt/php/bin/pecl install mcrypt-1.0.1. pecl is now the recommended way to install mcrypt, but it may not be included in Mojave. PEAR does include pecl. jasonmccreary.me/articles/install-pear-pecl-mac-os-x recommends curl -O http://pear.php.net/go-pear.phar, sudo php -d detect_unicode=0 go-pear.phar. Once PEAR is configured, run pecl install mcrypt-1.0.1

– EpicVoyage

Apr 17, 2019 at 17:49

I'm trying to run Laravel's repository and it throws this error:

Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128'

I've googled almost every link and couldn't solve it. So as I realize I need to install mcrypt extension.

So what I've tried is:

  1. brew intsall php71-mcrypt
  2. brew install mcrypt
  3. I've also tried to add extenstion=mcrypt.so in php.ini
  4. I tried to reboot nginx without success (nginx -s stop, nginx)

brew search mcyrpt shows that I got them installed

php -i | grep mcrypt shows:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php71/7.1.4_16/lib/php/extensions/no-debug-non-zts-20160303/mailparse.so' - dlopen(/usr/local/Cellar/php71/7.1.4_16/lib/php/extensions/no-debug-non-zts-20160303/mailparse.so, 9): image not found in Unknown on line 0 Additional .ini files parsed => /usr/local/etc/php/7.1/conf.d/ext-mcrypt.ini Registered Stream Filters => zlib.*, bzip2.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, mcrypt.*, mdecrypt.* mcrypt mcrypt support => enabled mcrypt_filter support => enabled mcrypt.algorithms_dir => no value => no value mcrypt.modes_dir => no value => no value

phpinfo() though shows only:

Additional .ini files parsed: /usr/local/etc/php/7.1/conf.d/ext-mcrypt.ini

Also I remember trying to install autoconf and some other things

I guess mcrypt works for php-cli, but not on web version

My php version is 7.1, nginx 1.12.0, mac os El Captain