Christer Fernstrom
Christer Fernstrom

Reputation: 618

Can't get mcrypt to work on OS X High Sierra and PHP 7.1

I need to use a Wordpress 3rd party plugin that uses mcrypt. mcrypt is not available as default in my environment (OSX High Sierra and PHP 7.1) (and I know that it is deprecated...) so I installed it with PECL. The installed mcrypt.so file was created in this location:

/usr/lib/php/extensions/no-debug-non-zts-20160303/

I have added the following to my php.ini:

extension=/usr/lib/php/extensions/no-debug-non-zts-20160303/mcrypt.so

And after that

php -i | grep mcrypt

returns

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

And

php -m | grep mcrypt

returns

mcrypt

To me this means that php now can use mcrypt.

I restart Apache, but still get a fatal error:

**Fatal error**: Uncaught Error: Call to undefined function mcrypt_module_open() in /User.....

And displaying a page with

<?php phpinfo(); ?>

does NOT show mcrypt among the modules. But IT IS the correct php.ini that is used. So to me this means that php can use mcrypt when started from the command line but not when used from Apache.

I also tried to uncomment the line

LoadModule php7_module libexec/apache2/libphp7.so

in httpd.conf, and restart apache, but the result is the same.

Any ideas?

Upvotes: 1

Views: 897

Answers (1)

Christer Fernstrom
Christer Fernstrom

Reputation: 618

As it turned out, this was a problem with Apache+PHP. I re-installed both Apache and PHP following the advice from here https://getgrav.org/blog/macos-sierra-apache-upgrade-homebrew (which since has been updated for the new version OSX 10.14 Mojave) and here: https://getgrav.org/blog/macos-mojave-apache-multiple-php-versions

I site from the former site:

The cleanest way to migrate from the old brew formulae to the new pecl package approach is to remove everything PHP-related and reinstall with the new instructions.

Upvotes: 0

Related Questions