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

4 Answers 4


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.

  • Or make use of the phpenmod utlility: echo "extension=mcrypt.so" | sudo tee -a /etc/php/7.2/mods-available/mcrypt.ini sudo phpenmod mcrypt
    – Werner
    Jan 25, 2020 at 0:50
  • Thanks @Epskampei
    – abu abu
    Jun 21, 2020 at 8:55
  • /etc/php/7.2/mods-available/mcrypt.ini: No such file or directory Feb 21, 2021 at 3:08

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
  • 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" ! May 5, 2018 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, 2018 at 23:32

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:


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

$ php -m | grep mcrypt

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.