I have solved same issue in PHP Version : 7.4.3 Ubuntu Version : 20.04.1 LTS and nginx
sudo apt-get install php-pear php7.4-dev
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install libmcrypt-dev
You can choose your mcrypt version according to php version Read
sudo pecl install mcrypt-1.0.4
When you are shown the prompt
libmcrypt prefix? [autodetect] :
Press [Enter] to autodetect.
The output will be something like this.
Build process completed successfully
Installing '/usr/lib/php/20190902/mcrypt.so'
install ok: channel://pecl.php.net/mcrypt-1.0.4
configuration option "php_ini" is not set to php.ini location
You should add "extension=mcrypt.so" to php.ini
After success installing mcrypt using pecl, you should add extension=/usr/lib/php/20190902/mcrypt.so extension to php.ini.
I have added extension=/usr/lib/php/20190902/mcrypt.so in bellow files
- /etc/php/7.4/fpm/php.ini
- /etc/php/7.4/cli/php.ini
Restart You nginx because i am using nginx
systemctl restart nginx
You can also restart php-fpm
sudo service php7.4-fpm restart
Finally how can verify mycrpt is installed or not (Note close your terminal and open again)
php -m | grep mcrypt