How to install mcrypt on php7.2 php7.3 php7.4

check php version

$ php -version

Install mcrypt extension

$ sudo apt-get -y install gcc make autoconf libc-dev pkg-config
$ sudo apt-get -y install libmcrypt-dev

if php version > 7.3.0

$ sudo pecl install mcrypt-1.0.2

if php version <= 7.3.0

$ sudo pecl install mcrypt-1.0.1

When you are shown the prompt (Press [Enter] to autodetect)

> libmcrypt prefix? [autodetect] :

enable 'mcrypt' in php.ini -> check if 'mcrypt' is already in php.ini and maybe just needs to be uncommented

$ more /opt/bitnami/php/etc/php.ini | grep mcrypt
;extension=mcrypt.so

add or uncomment 'extension=mcrypt.so' in php.ini

$ emacs /opt/bitnami/php/etc/php.ini

REFERENCES...