Nginx – Enabling mcrypt on mac os for nginx

mac-osxmcryptnginxPHP

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

Best Answer

Probably the php-fpm - the module used to load php in nginx is using different php.ini file and you have to enable mcrypt there.

To find which php.ini file uses nginx, create test.php file with:

<?php

phpinfo();

run it and search for php.ini in the response. You should find the location of the file.