How can I install mcrypt in the 8*-fpm version?

  • 7 августа 2023 г. 10:51
Ответы на вопрос 3
Installing the mcrypt extension depends on the Linux distribution as well. Here is how you can install it on Ubuntu:

To install the required libraries and PHP modules that are needed by mcrypt, you need to run the following commands:

```bash
sudo apt-get update
sudo apt-get install -y libmcrypt-dev
sudo apt-get install php-dev libmcrypt-dev php-pear
```

Then you need to install mcrypt itself using PECL, which is a repository for PHP Extensions.

```bash
sudo pecl channel-update pecl.php.net
sudo pecl install mcrypt-1.0.4
```

After successful installation, we have to add the extension to PHP configuration using:

```bash
echo "extension=mcrypt.so" | sudo tee /etc/php/8.0/mods-available/mcrypt.ini
```

Enable the mcrypt extension with the command:

```bash
sudo phpenmod mcrypt
```

Finally, restart the PHP-FPM service:

```bash
sudo service php8.0-fpm restart
```

The numbers "8.0" in the commands should be replaced with the version of PHP you're currently running.

This tutorial assumes that you have a Ubuntu Linux OS with PHP8-fpm installed. 

**Note**: As of PHP 7.2, the mcrypt extension was moved to the PECL repository and is no longer bundled with PHP. This means that it's no longer updated by the PHP team and might be removed from future versions of PHP.
Ставить mcrypt необязательно. Попробуйте использовать полифилл, который заменяет функции mcrypt через phpseclib: https://github.com/phpseclib/mcrypt_compat/tree/master.
Стоит использовать polyfill из библиотеки phpseclib вместо mcrypt, чтобы не переписывать весь код. Этот polyfill реализует все функции mcrypt и не требует установки самого mcrypt. Вы можете найти polyfill здесь: https://github.com/phpseclib/mcrypt_compat/tree/master
Похожие вопросы