I got an error when i execute this command

php bin/magento setup:upgrade &&
php bin/magento setup:di:compile &&
#php bin/magento setup:static-content:deploy &&
chown -R www-data:www-data . &&

rm -rf var/cache &&
rm -rf var/di &&
rm -rf var/page_cache/ &&
rm -rf var/generation/ &&
rm -rf var/view_preprocessed/

the error is

"Use of undefined constant MCRYPT_RIJNDAEL_256 - assumed 'MCRYPT_RIJ NDAEL_256"

when i was checking my server, and show the phpinfo(), the extension for mcrypt has been enabled properly, so what is the real problem? enter image description here

  • i also get same issue 1 exception(s): Exception #0 (Exception): Warning: Use of undefined constant MCRYPT_RIJNDAEL_256 - assumed 'MCRYPT_RIJNDAEL_256' (this will throw an Error in a future version of PHP) in ../vendor/magento/framework/Encryption/Encryptor.php on line 394
    – matinict
    Oct 24 '18 at 7:27
  • how to solve this issue. Dec 3 '18 at 11:09

This worked for me:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get install php7.1-mcrypt

Hope it help.


Magento 2.1 isn't made for php7.2 … It looks like you're using php7.2. so just switch back to php7.1 oder php7.0 and it should work fine :-)


Take a look at this https://stackoverflow.com/questions/29993399/use-of-undefined-constant-mcrypt-rijndael-128-assumed-mcrypt-rijndael-128

Run this in console

php -m | grep mcrypt

It should return


If not, be sure to enable module using phpenmod command

Another reference, for php5 http://php.net/manual/es/mcrypt.installation.php

Note, for Ubuntu, simply installing php5-mcrypt did not get mcrypt to work. You need to execute the following commands as root to enable it:

apt-get install php5-mcrypt

mv -i /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/

php5enmod mcrypt

service apache2 restart


I got this after upgrading to Magento 2.3.1 on PHP 7.1.28 on CentOS7 without installing mcrypt and then adding it after discovering it was still required during the upgrade process. Simply restarting php-fpm worked for me.

# systemctl restart php-fpm

For my situation, using MAMP for my Magento project running locally in OSX I receive this error when the wrong PHP version is being used because my .bash_profile is not being properly sourced or needs to be sourced again...

Make sure the php version and file you are suggesting to use are whats being used by the system by running:

$ which php

<---- in my case the php i am wanting to use is in the MAMP directory, so /user/bin/php is incorrect.

Once i source my bash_profile i am using the correct php and the error goes away.

Your bash_profile allows you to set a specific path for the php/mysql versions you are wanting to use, you could have a separate profile for each project if required:

$cat ~/.bash_profile  
/// below is an example of what you would use in your bash_profile in my case                                             
export PATH=/usr/bin:$PATH
export PATH=/Applications/MAMP/Library/bin:$PATH
export PATH=/Applications/MAMP/bin/php/php7.1.22/bin:$PATH

In order to use this bash profile you must 'source' the file.

$source ~/.bash_profile

Then when you check the php version it should return the correct path

$which php

Hope this helps someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.