3

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?

3 Answers3

12

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:

  1. Create a php file called info.php put this code in it:

    <?php echo phpinfo(); ?>
    
  2. Put the file in /var/www/html or your server root

  3. Access it from the brower at say IP/info.php or localhost/info.php

  4. Look at the out and you will find that mcrypt and mbstring are enabled

    enter image description here

    As you can see, its enabled in apache, but inaccessible from php CLI hence the error messages.

  5. 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.

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

George Udosen
  • 36,677
  • Brings ERROR: Module mcrypt does not exist!. –  Jan 02 '17 at 06:38
  • what version of php are you using ? – George Udosen Jan 02 '17 at 06:40
  • I use version 7.0.8. –  Jan 02 '17 at 06:41
  • Then do sudo apt install php7.0-mcrypt && sudo apt install php7.0-mbstring its like its not installed. – George Udosen Jan 02 '17 at 06:42
  • Wired, I was sure they would be installed with PHP7 from my command above. Maybe it's a temporary bug? –  Jan 02 '17 at 06:52
  • Never assume any thing with computers or software, just double check to be sure. – George Udosen Jan 02 '17 at 06:55
  • Thumbed up! Adding a soft shortlink solved it. –  Jan 04 '17 at 03:56
  • @Benia AFAIK doing sudo a2enmod module_name actually does the same thing as ln -s /etc/php7/conf.d/module.ini /etc/php/7.0/mods-available/module.ini. So simple doing a2enmod will create that symbolic link for you. – George Udosen Jan 04 '17 at 11:08
  • Reposting: 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. –  Jan 04 '17 at 11:11
  • George, I'll check this asap. –  Jan 04 '17 at 11:11
  • You may also check in /etc/php7/apache2/conf.d, similar to /etc/php7/conf.d/ depending on your system. – George Udosen Jan 04 '17 at 11:17
  • Wired, I've installed a new server environment from a script but now either a2enmod or ln -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 get update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults. –  Jan 04 '17 at 11:27
  • How 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 using systemd in Ubuntu 16.04. Hence if you want to say reload apache2 you would do sudo systemctl restart apache2 rather than sudo service apache2 restart – George Udosen Jan 04 '17 at 11:33
  • 1
    I was wrong. The links are created, but still ERROR: Module mbstring does not exist!. ERROR: Module mcrypt does not exist!. –  Jan 04 '17 at 11:39
  • If you receive this comment respond found a solution. – George Udosen Jan 04 '17 at 16:02
  • Sure, entering to chat. –  Jan 04 '17 at 16:30
  • Replied there now. –  Jan 04 '17 at 17:13
5

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
theINtoy
  • 151
1

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