113

The php mcrypt extension on ubuntu 14.04 shows that it is installed properly, but phpmyadmin says:

 The mcrypt extension is missing. Please check your PHP configuration.

My current php config is here. If you need anymore information, please contact me through the comments.

$ sudo apt-get install php5-mcrypt
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    php5-mcrypt is already the newest version.
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2
  • 7
    The accepted answer is not best practice. The simplest, and correct answer: http://askubuntu.com/a/477608/139249 also has the most votes. Feb 3, 2015 at 18:02
  • For others' reference, the "simplest" answer did not work for me. php5enmod mcrypt froze up Apache. php5dismod mcrypt freed it up again. I went with the accepted answer and modified the path for extension=.. and this time php5enmod mcrypt worked. So yes, it's comprehensive and should be the accepted answer. Jan 26, 2017 at 23:35

14 Answers 14

155

Try just doing this:

sudo php5enmod mcrypt

And then:

sudo service apache2 restart 

I have installed fresh Ubuntu 14.04 (desktop version) to my computer. This way works for enabling mcrypt that was already installed.

3
  • 5
    Note, if you're running nginx with php5-fpm -- then php5-fpm service restart (or reload if it's finally patched) Feb 3, 2015 at 17:54
  • 2
    What those two command do is this: the 1st line is enabling module named 'mcrypt', and then restart apache2 to update the config. You can see the enabled module from /etc/apache2/mods-available. Enjoy LAMP life :)
    – kenju
    Oct 21, 2015 at 9:57
  • sudo service apache2 reload is enough, no actual restart is needed (on 14.04 anyway, that's what I tried it on)
    – Jasper
    Jan 10, 2016 at 16:42
139

Try this:

sudo updatedb 
locate mcrypt.ini

Should show it located at /etc/php5/mods-available

locate mcrypt.so

Edit mcrypt.ini and change extension to match the path to mcrypt.so, example:

extension=/usr/lib/php5/20121212/mcrypt.so

Now this:

sudo php5enmod mcrypt - (optional since its already enabled during phpmyadmin setup)

Verify that new files exists here (they should be auto created from the issue above)

ls -al /etc/php5/cli/conf.d/20-mcrypt.ini
ls -al /etc/php5/apache2/conf.d/20-mcrypt.ini

Otherwise do the following

Create symbol links now

sudo ln -s /etc/php5/mods-available/mcrypt.ini /etc/php5/cli/conf.d/20-mcrypt.ini
sudo ln -s /etc/php5/mods-available/mcrypt.ini /etc/php5/apache2/conf.d/20-mcrypt.ini

Restart Apache

sudo service apache2 restart

Restart php5 or php5-fpm

sudo service php5 restart
9
  • This is wrong! I think you meant something like: sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/mcrypt.ini And not the other way around.
    – AturSams
    Sep 3, 2014 at 14:22
  • 14
    Doing just php5enmod mcrypt worked smoothly for me.
    – Diosney
    Jan 6, 2015 at 21:44
  • 3
    Running php5enmod mcrypt will create those symbolic links for you. No need to do that manually (i.e. you can skip the ln -s commands). Jan 16, 2015 at 21:15
  • 1
    running php5enmod mcrypt is the correct Ubuntu/Debian way. This answer though will work, is cumbersome and not a best practice. Feb 3, 2015 at 17:45
  • 1
    many steps of above are not necessary. See @MURATSPLAT's answer.
    – Raptor
    Oct 15, 2015 at 9:29
55

Install mcrypt extension for PHP, Enable it, and Restart Apache. Following are the commands to do:

sudo apt-get install mcrypt php5-mcrypt
sudo php5enmod mcrypt
sudo service apache2 restart
4
  • 1
    Simple. Perfect. Works without issues, at least for me on Ubuntu 14.04.1 LTS (trusty)
    – Gor
    Dec 19, 2014 at 20:15
  • It's working on ubuntu 14.10 too
    – Coca Akat
    Apr 21, 2015 at 9:12
  • I would recommend you don't include mcrypt in your first line. It is implicitly installed as a dependency of php5-mcrypt, but if you explicitly install it apt-get won't know to remove it if you later choose to un-install the ph5-mcrypt package.
    – beldaz
    Sep 17, 2015 at 20:39
  • @beldaz there is at least one server where php5-mcrypt was installed as per apt-get but mcrypt was missing because of which pnp module was not getting enabled leading to joomla installation issue. so including mcrypt makes sense for me.
    – tagMacher
    Sep 21, 2016 at 8:27
6

The php5-mcrypt Ubuntu package install the config file mcrypt.ini into /etc/php5/conf.d/ which is the old PHP config directory layout.

The current way of working to enable modules in PHP5 is to put the ini files in the /etc/php5/mods-available directory. Then, to enable the module in PHP5, you have to create a symbolic link to the related ini files from /etc/php5/apache2/conf.d directory to enable the module when PHP is used under Apache or / and from /etc/php5/cli/conf.d if you want to have this module enabled when you use PHP outside Apache, in scripts run at the command line or from crontab.

Also note that in the conf.d directory, you can create the link to the ini file by putting a number in front of it to have the modules loaded in a specific order. Usefull when you need to load a module depending on another one.

Of course, don't forget to restart Apache if you have enabled the module for Apache :

 sudo service apache2 restart
4

My 14.04 server install only needed (after php5-mcrypt installed)

sudo php5enmod mcrypt
sudo service apache2 restart
3

If the Problem still occurs,

enable the module by adding: extension=mcrypt.so to

/etc/php5/cli/php.ini

and

/etc/php5/apache2/php.ini

3
  • 1
    For me adding the 'extension=mcrypt.so' worked after installing the mcrypt. Lubuntu 14.04 Trusty Thar Apr 23, 2015 at 4:35
  • This works and is WAY simpler then the accepted answer... which will also break when it updates.
    – Eric
    Dec 11, 2015 at 18:32
  • I followed every instruction here and in other places but in vain. ubuntu 14.04.3 -- PHP 5.5.9-1ubuntu4.14 -- nginx/1.8.1 -- Server version: 5.7.10 - MySQL -- Database client version: libmysql - 5.5.47 -- phpMyAdmin Version: 4.0.10deb1....anyone have an idea?
    – Jadeye
    Feb 2, 2016 at 9:21
2

In Ubuntu 16.04 LTS, to enable the mcrypt module, with php 5.6:

sudo apt-get install mcrypt
sudo apt-get install php5.6-mcrypt
sudo phpenmod mcrypt

or with php 7.0:

sudo apt-get install mcrypt
sudo apt-get install php7.0-mcrypt
sudo phpenmod mcrypt

and then

sudo service apache2 restart
1

With PHP 7

sudo apt-get install php-mcrypt
sudo phpenmod mcrypt
sudo /etc/init.d/apache2 restart
2
  • $ sudo phpenmod mcrypt WARNING: Module mcrypt ini file doesn't exist under /etc/php/7.1/mods-available Dec 15, 2016 at 1:56
  • $ sudo /etc/init.d/apache2 restart sudo: /etc/init.d/apache2: command not found Dec 15, 2016 at 1:57
0

You should be able to install the mcrypt extension for PHP by running:

sudo apt-get install php5-mcrypt
3
  • well, it says that it (command line) is installed properly, but it is somehow missing from the server as mentioned above May 5, 2014 at 0:06
  • 1
    @jkt123: I've noticed that when you install some php module like php5-mcrypt in Ubuntu, all the files are there afterward but the module is not enabled in the main PHP config. You have to activate it manually like described in the accepted answer.
    – Benoit
    Jun 6, 2014 at 12:19
  • it does not work without adding the extension=mcrypt.so to php.ini
    – Eric
    Dec 11, 2015 at 18:30
0

Note that in Ubuntu 14.04 the php5-mcrypt is in the universe repository that could be disabled. In this case to install it you must enable the repository with:

sudo add-apt-repository universe
0

You need to enable the mcrypt module:

sudo php5enmod mcrypt
sudo service apache2 restart
0

This is the best way to add php 5.5 mcrypt extension on Ubuntu 14.04 Server

sudo apt-get install php5-mcrypt
sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available
sudo php5enmod mcrypt 
sudo service apache2 restart
0

@Kevsin's answer worked for me, but I had to run mkdir -p /etc/php5/apache2/conf.d/ and manually run the sudo ln -s /etc/php5/mods-available/mcrypt.ini /etc/php5/apache2/conf.d/20-mcrypt.ini to get to work. sudo php5enmod mcrypt worked fine for the first symlink.

Note: I'm running PHP5-FPM. That may have been the difference.

0

For those who find this, for Ubuntu 16.04 (using PHP7), here is what I did to enable mcrypt:

sudo apt-get install mcrypt php-mcrypt
sudo phpenmod mcrypt
sudo service apache2 restart

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .