phpenmod mcrypt and phpenmod mbstring return errors
Solution 1
Install them first:
sudo apt install php7.0-mcrypt && sudo apt install php7.0-mbstring
Then enable them with:
sudo a2enmod mcrypt
sudo a2enmod mbstring
Update
Based on the extensive research I believe a bug exist that prevents your php cli working well with php mcrypt.
Source:
Can't use PHP extension Mcrypt in Ubuntu 13.10 (Nginx, PHP-FPM)
php is not working well on ubuntu 13.10 and mcrypt is missing in phpmyadmin
To confirm that mcrypt
is enabled in apache follow these steps:
-
Create a
php
file calledinfo.php
put this code in it:<?php echo phpinfo(); ?>
Put the file in
/var/www/html
or your server rootAccess it from the brower at say
IP/info.php
orlocalhost/info.php
-
Look at the out and you will find that
mcrypt and mbstring
are enabledAs you can see, its enabled in apache, but inaccessible from php CLI hence the error messages.
-
To confirm its working [as I have this problem also] I did the following:
- installed prestashop application, and since one of the requirements of prestashop is php mcrypt it would have thrown an error and refused to proceed if
mcrypt
was not enabled on apache.
- installed prestashop application, and since one of the requirements of prestashop is php mcrypt it would have thrown an error and refused to proceed if
Simple put based on your the if your apache information page displays these modules as enabled then it is. The error seen are a result of php CLI having issues with mcrypt which has been noted to be a bug. Seen in earlier versions of php but now present in php 7
Solution 2
I had issues with the above solutions but found this:
https://www.techrepublic.com/article/how-to-install-mcrypt-for-php-7-2/
Essentially, build it yourself:
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install php7.2-dev
sudo apt-get -y install libmcrypt-dev
Once the dependencies have been installed, you can install mcrypt with the command:
sudo pecl install mcrypt-1.0.1
From there I needed to add:
/etc/php/7.2/mods-available/mcrypt.ini
Which looked like this:
; configuration for php mcrypt module
; priority=20
extension=mcrypt.so
Then
sudo phpenmod mcrypt
sudo systemctl restart apache2.service
Solution 3
If their both installed and the error persist, Try to make a symlink to ini files in mods-available
Here is how to do it:
sudo ln -s /etc/php7/conf.d/mcrypt.ini /etc/php/7.0/mods-available/mcrypt.ini
sudo ln -s /etc/php7/conf.d/mbstring.ini /etc/php/7.0/mods-available/mbstring.ini
Related videos on Youtube
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Admin
Updated on September 18, 2022Comments
-
Admin almost 2 years
I use a minimal server environment of ubuntu16.04.1, Apache2, MySQL and PHP 7.0.8.1. I've installem AMP via:
apt-get install lamp-server^
.I also installed PHPmyadmin manually via:
cd /var/www/html wget https://files.phpmyadmin.net/phpMyAdmin/4.6.5.2/phpMyAdmin-4.6.5.2-all-languages.zip find ./ -type f -name '*phpMyAdmin*.zip' -exec unzip {} \; # We can also do unzip \*phpMyAdmin*.zip ... find ./ -type d -name 'phpMyAdmin-*' -exec mv {} phpmyadmin \;
PHPmyadmin is bootstrapped but to use it fully functionally, AFAIK I aslo need to do:
phpenmod mcrypt phpenmod mbstring
Yet these respectively return errors:
Module mcrypt ini file doesn't exist under /etc/php/7.0/mods-available Module mbstring ini file doesn't exist under /etc/php/7.0/mods-available
I never had these errors before. Are these modules redundant for PHPmyadmin in current releases or when not installed via
apt-get install
?-
George Udosen over 7 yearstry
sudo a2enmod mcrypt
andsudo a2enmod mbstring
-
muru over 7 yearsYou did install
php-mcrypt
andphp-mbstring
, right? -
George Udosen over 7 yearsIs the issue resolved ?
-
Admin over 7 yearsIt seems I can access PMA without installing these as you shown in the answer so I wonder if there is an issue at all (the only reason I wanted to install this is because I thought they are missing for PMA but it seems in latest releases we just dont need them).
-
-
Admin over 7 yearsBrings
ERROR: Module mcrypt does not exist!
. -
George Udosen over 7 yearswhat version of
php
are you using ? -
Admin over 7 yearsI use version 7.0.8.
-
George Udosen over 7 yearsThen do
sudo apt install php7.0-mcrypt && sudo apt install php7.0-mbstring
its like its not installed. -
Admin over 7 yearsWired, I was sure they would be installed with PHP7 from my command above. Maybe it's a temporary bug?
-
George Udosen over 7 yearsNever assume any thing with computers or software, just double check to be sure.
-
Admin over 7 yearsThumbed up! Adding a soft shortlink solved it.
-
George Udosen over 7 years@Benia AFAIK doing
sudo a2enmod module_name
actually does the same thing asln -s /etc/php7/conf.d/module.ini /etc/php/7.0/mods-available/module.ini
. So simple doinga2enmod
will create that symbolic link for you. -
Admin over 7 yearsReposting: Looking back, creating symlinks as in Arduino_sentinel's answer is not enough and I first need to install these, as in George's answer. Both answers are correct.
-
Admin over 7 yearsGeorge, I'll check this asap.
-
George Udosen over 7 yearsYou may also check in
/etc/php7/apache2/conf.d
, similar to/etc/php7/conf.d/
depending on your system. -
Admin over 7 yearsWired, I've installed a new server environment from a script but now either
a2enmod
orln -s
works... Yet when I try to reinstall I get (for example):php7.0-mcrypt is already the newest version (7.0.8-0ubuntu0.16.04.3). 0 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.
... I just tried to upgrade and it didn't help --- Both methods still don't work. Moreover, after upgrading I getupdate-rc.d: warning: start and stop actions are no longer supported; falling back to defaults
. -
George Udosen over 7 yearsHow do you know its not working ? It says already newest version hence its there already. The
update-rc.d
is for the old Upstart system, you should be usingsystemd
in Ubuntu 16.04. Hence if you want to say reload apache2 you would dosudo systemctl restart apache2
rather thansudo service apache2 restart
-
George Udosen over 7 yearsLet us continue this discussion in chat.
-
Admin over 7 yearsI was wrong. The links are created, but still
ERROR: Module mbstring does not exist!
.ERROR: Module mcrypt does not exist!
. -
George Udosen over 7 yearsIf you receive this comment respond found a solution.
-
Admin over 7 yearsSure, entering to chat.
-
Admin over 7 yearsReplied there now.
-
Abhishek Pachal over 3 yearsthis solution worked for me