How to fix E: Couldn’t find any package by regex ‘php7.0-mcrypt’, Couldn’t find any package by regex ‘php-mcrypt’
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$ sudo apt update $ sudo apt install php-mcrypt Reading package lists... Done Building dependency tree Reading state information... Done Package php-mcrypt is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package 'php-mcrypt' has no installation candidate |
You are facing the above issue when trying to resolve mcrypt
Here are steps for the solution
Tell your Ubuntu OS to pull the latest list of packages
1 2 3 4 5 |
sudo apt update |
Install Development tools on Ubuntu
1 2 3 4 5 |
sudo apt install -y build-essential |
Confirm gcc:
1 2 3 4 5 |
gcc --version |
You will get a response
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Make gcc:
1 2 3 4 5 |
make --version |
You will get a response
GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law
You must first install dev and pear extensions on Ubuntu.
1 2 3 4 5 |
sudo apt install php-pear php-dev libmcrypt-dev |
Confirm pecl command is available in your system.
1 2 3 4 5 |
which pecl |
You will get a response
/usr/bin/pecl
Update channels:
1 2 3 4 5 |
sudo pecl channel-update pecl.php.net |
You will get a response
Updating channel “pecl.php.net”
Update of Channel “pecl.php.net” succeeded
1 2 3 4 5 |
sudo pecl update-channels |
You will get a response
Updating channel “doc.php.net”
Update of Channel “doc.php.net” succeeded
Updating channel “pear.php.net”
Update of Channel “pear.php.net”
succeeded Updating channel “pecl.php.net”
Channel “pecl.php.net” is up to date
search for mcrypt extension.
1 2 3 4 5 |
sudo pecl search mcrypt |
You will get a response
=======================================
Package Stable/(Latest) Local
mcrypt 1.0.5 (stable) 1.0.5 Bindings for the libmcrypt library
mcrypt_filter 0.1.0 (beta) Applies mcrypt symmetric encryption using stream filter
You need to install mcrypt extension using pecl command with the install option.
1 2 3 4 5 |
sudo pecl install mcrypt |
When you see a prompt
1 2 3 4 5 |
libmcrypt prefix? [autodetect] : |
Press Enter to autodetect.
Enable the extension in php.ini file. You can usevim
editor:
1 2 3 4 5 |
sudo vim /etc/php/*/cli/php.ini |
add extension=mcrypt.so after list of extension like below
;extension=pdo_sqlite
;extension=pgsql
;extension=shmop
extension=mcrypt.so
1 2 3 4 5 |
sudo vim /etc/php/*/apache2/php.ini |
add extension=mcrypt.so after list of extension like below
;extension=pdo_sqlite
;extension=pgsql
;extension=shmop
extension=mcrypt.so
You can confirm that the module was installed and enabled with the command:
1 2 3 4 5 |
php -m | grep mcrypt |
Response mcrypt
Restart Apache web server If apache2
1 2 3 4 5 |
sudo systemctl restart apache2 |
Restart nginx web server If nginx
1 2 3 4 5 |
sudo systemctl restart nginx |
More Stories
How to set EC2 Ubuntu default password
CPU & Memory usage in PHP
PHP Composer memory limit issues