October 1, 2022

WeAnswer

The complete guide to the beginners as well as to the experienced Web Developers

Install PHP mcrypt extension on Ubuntu

How to fix E: Couldn’t find any package by regex ‘php7.0-mcrypt’, Couldn’t find any package by regex ‘php-mcrypt’

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

Install Development tools on Ubuntu

Confirm  gcc:

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:

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.

Confirm pecl command is available in your system.

You will get a response

/usr/bin/pecl

Update channels:

You will get a response

Updating channel “pecl.php.net”

Update of Channel “pecl.php.net” succeeded

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.

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.

When you see a prompt

Press Enter to autodetect.

Enable the extension in php.ini file. You can usevim editor:

add extension=mcrypt.so after list of extension like below

;extension=pdo_sqlite

;extension=pgsql

;extension=shmop

extension=mcrypt.so

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:

Response mcrypt

Restart Apache web server If apache2

Restart nginx web server If nginx