30

Is the php-mcrypt package missing in Ubuntu Server 18.04 LTS?

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
Melebius
  • 11,431
  • 9
  • 52
  • 78
  • Ubuntu php-mcrypt : https://packages.ubuntu.com/search?lang=en&keywords=php-mcrypt&searchon=names ... No php-mcrypt for 18.04 . – Knud Larsen May 04 '18 at 18:28

4 Answers4

41

Mcrypt has been deprecated in PHP 7.2, so it's not available by default.

You can still install the mcrypt extension using pecl. These instructions are for the apache web server.

# Install prerequisites
sudo apt-get install php-dev libmcrypt-dev gcc make autoconf libc-dev pkg-config

# Compile mcrypt extension
sudo pecl install mcrypt-1.0.1
# Just press enter when it asks about libmcrypt prefix

# Enable extension for apache
echo "extension=mcrypt.so" | sudo tee -a /etc/php/7.2/apache2/conf.d/mcrypt.ini

# Restart apache
sudo service apache2 restart

That should get you going.

In the long term you might want to replace mcrypt, it's deprecated for a reason.

Epskampie
  • 697
11

I did the following to get this working...

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

If you're running php5.6 or 7.0 then you can use the following

sudo apt-get install php5.6-mcrypt
sudo apt-get install php7.0-mcrypt
DanBarber
  • 111
  • 1
    Ubuntu 18.04 has php7.2 in fact after added ppa repository and installet php7.1-mcrypt, when i do a2enmod mcrypt the response is "module mcrypt is not exists" ! – Andrea Rossetti May 05 '18 at 21:01
  • you're likely using php 7.2 (/etc/php/7.2) -- this installs it to 7.1 (/etc/php/7.1/) and only works if you also install/use that version of php apt-get install php7.1 – Alvin Jul 27 '18 at 23:32
5

First Check whether the mcrypt PHP module is present:

$ php -m | grep mcrypt

To install the mcrypt PHP module we first need to satisfy the following prerequisites:

sudo apt install php-dev libmcrypt-dev php-pear

Now we are ready to install mcrypt PHP module on our Ubuntu 18.04 system:

$ sudo pecl channel-update pecl.php.net
$ sudo pecl install mcrypt-1.0.1

Open the /etc/php/7.2/cli/php.ini file and insert:

extension=mcrypt.so

All done. When successful, checking for the presence of the mcrypt PHP module should produce the following output:

$ php -m | grep mcrypt
mcrypt

References

andrew.46
  • 38,003
  • 27
  • 156
  • 232
  • Please be more scrupulous with referencing sources, I have added in the appropriate link. Please read here: https://meta.askubuntu.com/q/19789/57576 – andrew.46 Jan 04 '23 at 00:25
4

php mcrypt has been removed in php 7.2 http://php.net/manual/en/migration71.deprecated.php