1

I'm using MAMP and ive installed a fresh version of Opencart, its telling me i dont have MCrypt enabled, when i go to terminal and type:

php -m | grep mcrypt
output: mcrypt

I can locate the library but it doesn't seem to be enabled.

Emre Bolat
  • 4,316
  • 5
  • 29
  • 32
Anton Bahrencheer
  • 41
  • 1
  • 1
  • 10
  • http://stackoverflow.com/a/26460719/3635079 – dhruv jadia Feb 28 '17 at 09:29
  • I don't think i can use that answer it's from 2014 and we're on php 7 now, thanks tho :) – Anton Bahrencheer Feb 28 '17 at 09:36
  • _“I can locate the library but it doesn't seem to be enabled”_ – so enable it then …? What did you try to achieve that, and with what results? – CBroe Feb 28 '17 at 09:42
  • @CBroe I don't know how to enable it, im not that good at server configurations and library extensions. I looked into the php ini file and could only find one occurrence "extension=mcrypt.so" – Anton Bahrencheer Feb 28 '17 at 09:47
  • instead of posting here, you should check it's documentation – Sagar V Feb 28 '17 at 09:49
  • @SagarV Well all i can find on the subject is that you have to write exactly what is in my php ini file "extension=mcrypt.so" to require the library if you have another documentation that explanes it better feel free to link it, i just cant personally find any. Posting here was my last resort. – Anton Bahrencheer Feb 28 '17 at 09:53

5 Answers5

6

That fact that php -m | grep mcrypt returns mcrypt, means the mcrypt library is INSTALLED and ENABLED.

Although it may just be enabled for CLI.

You can try editing the PHP.ini file and adding the following line under the ; Extensions section:

extension=mcrypt.so

Restart Apache / MAMP after saving php.ini file.

To find the correct php.ini file to edit, run the following command line:

php --info | grep php.ini

(If the line already exists, you may just need to remove the ; thats in front of it.)

Niraj Shah
  • 15,087
  • 3
  • 41
  • 60
  • It's not being detected enable by Opencart https://gyazo.com/3917b79c77579b3e2edb5fc7d523b33c – Anton Bahrencheer Feb 28 '17 at 10:02
  • Answer update. Posted too quickly! Restart MAMP after editing .ini file. – Niraj Shah Feb 28 '17 at 10:04
  • "extension=mcrypt.so" has been in the ini file all along thats why i don't get it, i have restarted it multiple times with no effect, It doesn't have a semi colon after it. – Anton Bahrencheer Feb 28 '17 at 10:06
  • Your system may have more than one php.ini file in use. Run `php --info | grep php.ini` and make sure correct `php.ini` file has been edited to enable mcrypt. – Niraj Shah Feb 28 '17 at 10:26
  • Use phpinfo() in a script file you call via HTTP (not command line), and check the header for which php.ini is actually used, to confirm that you are editing the correct one. – CBroe Feb 28 '17 at 10:26
  • @NirajShah Thanks that seemed to work i was apparently using some other .ini file, weird that the mamp phpinfo said i was using the other one then, oh well thanks alot i should be able to get it to work now :) – Anton Bahrencheer Feb 28 '17 at 10:39
4

I have tried so many ways but had no luck. After a lot of trials finally came up with a solution. Go to bin directory inside current active PHP version directory. In my case it is /Applications/MAMP/bin/php/php7.2.8/bin It might be different in your case. Now run the below command with sudo

sudo ./pecl install channel://pecl.php.net/mcrypt-1.0.1

Now You should add extension=mcrypt.so to php.ini Restart MAMP Service and check if it is working.

3

I had this issue following upgrading to MAMP 5.1 and using PHP 7.1.20...

The issue I found was not that MAMP PHP did not have mcrypt installed, it certainly does come bundled.

The issue was that the MAMP PHP configuration option "Make this version available on the command line" was NOT working and so the version of PHP I was using on the command line [in my case] was the macOS default PHP 7.1.16 without mcrypt (the version included in macOS by default)

Reverting to the old cli php alias meant the correct MAMP version of PHP was used on the command line

Added to .bash_profile

alias php='/Applications/MAMP/bin/php/php7.1.20/bin/php'
Flipmedia
  • 490
  • 4
  • 16
  • I did the same thing. I use php like every day outside of MAMP. I needed MAMP so I could run php 5.4. I did something like that, but I needed to not overwrite my current php command. so I did this: alias mphp="/Applications/MAMP/bin/php/php5.4.45/bin/php" – dustbuster Sep 06 '19 at 20:17
2

try in console

pecl install mcrypt
Alex
  • 769
  • 1
  • 11
  • 18
1

Using Brew:

  1. Install mcrypt: brew install mcrypt
  2. In Mamp: File -> Edit Template -> PHP (php.ini)-> {PHP version}
  3. Find 'Dynamic Extensions' in the text and add the following below (after the lines starting with ';'):

    extension=mcrypt.so

  4. Save, restart and test (with php -i | grep mcrypt for example)

Tum
  • 6,937
  • 2
  • 25
  • 23
  • I tried this. But `php -m | grep mcrypt Warning: PHP Startup: Unable to load dynamic library 'mcrypt.so' (tried: /Applications/MAMP/bin/php/php7.4.12/lib/php/extensions/no-debug-non-zts-20190902/mcrypt.so (dlopen(/Applications/MAMP/bin/php/php7.4.12/lib/php/extensions/no-debug-non-zts-20190902/mcrypt.so, 9): image not found), /Applications/MAMP/bin/php/php7.4.12/lib/php/extensions/no-debug-non-zts-20190902/mcrypt.so.so (dlopen(/Applications/MAMP/bin/php/php7.4.12/lib/php/extensions/no-debug-non-zts-20190902/mcrypt.so.so, 9): image not found)) in Unknown on line 0 $ ` – anjanesh Jun 18 '21 at 05:16