Pecl install php mcrypt

How to install PHP Mcrypt extension on Ubuntu 20.04 or Debian

PHP Mcrypt extension provides encryption facilities to web applications that need the functionality of modern algorithms such as AES. This extension works as an interface to the Mcrypt’s libmcrypt library which implements all the algorithms and modes found in it such as DES, TripleDES, Blowfish (default), SAFER-SK128, LOKI97, GOST, RC2, RC6, MARS, IDEA, RIJNDAEL-128 (AES), RIJNDAEL-192, TWOFISH, TEA, RC2, and more. However, PHP developers have removed it from the PHP package bundle since the launch of php7.2 because of no further development in Mcrypt, thus the extension also gets decrypted. Sodium (available as of PHP 7.2.0) and OpenSSL are now some alternatives to it.

However, the PHP Mcrypt extension has been moved to the PECL repository, thus if somebody wants, he or she can install it on Ubuntu 20.04 LTS using Pear. Here we will show how?

Читайте также:  What is python pep8

Open Command terminal and run system update

Go to Terminal, if you are using CLI server then you are already there. Simply run the system update command to refresh the repo cache and update the installed packages of the system.

Install Developer tools & Dependencies

To install PHP Mcrypt on Ubuntu 20.04 or Debian, we have to install some tools needed to build packages from the source along with some developer dependency packages.

sudo apt install gcc make autoconf libc-dev pkg-config libmcrypt-dev php-pear php-dev

Channel-update for PEAR and PECL

The below two commands will update the channels that allow Pear and Pecl to fetch packages-

pecl channel-update pecl.php.net pecl update-channels

Install Php Mcrypt extension on Ubuntu 20.04 or Debian

Finally, use the Pecl command to download and install php-mcrypt extension on your system

Enable “extension=mcrypt.so” via php.ini

Once the installation is complete to activate the extension we have to add it in the php.ini file of the system. For that simply edit the php.ini file and under Dynamic extension, type: extension=mcrypt.so beside other extensions, as shown in the screenshot.

sudo nano /etc/php/*/apache2/php.ini

Save the file ctrl+X, type Y, and hit the Enter key.

Install php Mcrypt Extension on Ubuntu 20.04

Restart Apache

To ensure your web server has successfully recognized the enabled PHP mcrypt extension, reload the Apache server-

sudo systemctyl reload apache2

Confirm Mcrypt is enabled

The output will be-

Other Tutorials-

2 thoughts on “How to install PHP Mcrypt extension on Ubuntu 20.04 or Debian”

Thanks a lot.But one more step should be inserted before checking if mcrypt is enabled.
We also need add ‘extension=mcrypt.so’ to /etc/php/7.4/cli/php.ini . Reply

What happens when pecl install mcrypt-1.0.4 says
configure: error: mcrypt.h not found. Please reinstall libmcrypt. Reply

Leave a Comment Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Источник

Как установить MCrypt для PHP 7.x

Расширение MCrypt предназначено для шифрования/дешифрования данных. Оно было признано устаревшим и в итоге, начиная с версии PHP 7.2 его убрали из ядра php. Однако, могут возникнуть ситуации, когда это расширение может понадобится, когда, например, вы работаете с какой-то устаревшей cms или просто старой программой и нет времени или желания переделывать программу.

Расширение MCrypt было перенесено в PECL по адресу https://pecl.php.net/package/mcrypt. На момент написания статьи последняя версия 1.0.3, которая поддерживает PHP 7.2, PHP 7.3 и PHP 7.4, а так же обещает поддержку PHP 8, который пока еще не вышел.

Как установить MCrypt для PHP 7.2, 7.3, 7.4 для Linux

Необходимо выполнить обновление репозитария и затем установить расширение:

$ sudo pecl channel-update pecl.php.net $ sudo pecl install mcrypt-1.0.3
sudo apt-get -y install gcc make autoconf libc-dev pkg-config sudo apt-get -y install libmcrypt-dev sudo pecl install mcrypt-1.0.3

После установки найдите куда установился файл mcrypt.so. Скорее всего это /usr/lib/php/modules/mcrypt.so или /usr/lib64/php/modules/mcrypt.so

Затем нужно найти php.ini. Не могу указать точный путь, т.к. на разных системах это могут быть абсолютно разные места, например, /etc/php.ini, либо /etc/php/7.2/cli/php.ini или /opt/php72/etc и др. Так же, php.ini может быть в папке пользователя.

В php.ini найдите где добавляются другие расширения (строки начинающиеся «extension margin-top:1em;»>Как установить MCrypt для PHP 7.2, 7.3, 7.4 для Windows

Скачайте архив расширения со страницы PECL https://pecl.php.net/package/mcrypt/1.0.3/windows для нужной версии PHP. Если не уверены, какая именно версия Thread Safe (TS) x86, Non Thread Safe (NTS) x86 или тоже x64 нужна, скачайте все четыре версии. Потом просто попробуете каждую из них и какая заработает, ту и оставите.

В скачанном архиве вам нужен файл php_mcrypt.dll — его нужно распаковать в папку, где установлен ваш PHP в подкаталог ext, где находятся и все другие расширения.

В php.ini найдите где добавляются другие расширения (строки начинающиеся «extension » src=»https://codernotes.ru/images/1572757006_install_mcrypt.JPG» style=»width:100%;max-width:995px;»/>

На этом установка MCrypt для PHP 7.2, 7.3, 7.4 завершена.

Источник

Pecl install php mcrypt

Note, for Ubuntu, simply installing php5-mcrypt did not get mcrypt to work. You need to execute the following commands as root to enable it:

apt-get install php5-mcrypt
mv -i /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/
php5enmod mcrypt
service apache2 restart

I needed to install mcrypt on Mac OS X Mavericks 10.9 for installing the Laravel 5 framework. I entered in the Terminal command line:

brew tap josegonzalez/homebrew-php
brew install php54 php54-mcrypt

This installed Mcrypt. In Terminal type php -i to see a list of everything installed or for much better formatting and easier to read make a phpinfo.php page with this inside

You can install Mcrypt from the PHP Source Tree as a module if you choose.

You first need to ensure you have libmcrypt, libmcrypt-devel, and mcrypt installed, then do:

# cd php-5.x.x/ext/mcrypt
# phpize
# aclocal
# ./configure
# make && make install

Enable the module by adding: ‘extension=mcrypt.so’ to PHP.ini.

Very handy if you need to install a single module and you may have installed PHP via RPM, but don’t wish to recompile your whole PHP install.

If you don’t have a /etc/php5/conf.d directory, you can simply only do: php5enmod mcrypt

On Ubuntu 14.04 LTS using php5-fpm with Nginx, I had to symlink the mcrypt.ini to the correct location, and then restart php5-fpm and nginx.
#ln -s /etc/php5/mods-available/mcrypt.ini /etc/php5/fpm/conf.d/mcrypt.ini
#service php5-fpm restart
#service nginx restart

If using a Debian-based Linux system, you can run the following commands:

sudo apt-get install php5-mcrypt
sudo /etc/init.d/apache2 restart

Источник

How To Install MCrypt For PHP 8 On Ubuntu 20.04 LTS

It provides the steps required to install MCrypt for PHP 8 on Ubuntu 20.04 LTS.

If you are using the most recent versions of PHP and your project depends on MCrypt, you will get the error specific to Encrypt library which requires MCrypt extension. The main reason for missing MCrypt is that PHP no longer provides it by default and we must explicitly install it in order to continue using it.

Notes: This tutorial assumes that most recent version of PHP is already installed on the system. You can also follow the tutorial How To Install PHP 8 On Ubuntu 18.04 LTS and How To Install PHP 8 On Ubuntu 20.04 LTS to install PHP 8 on Ubuntu.

Verify PHP

We can check the PHP version using the command as shown below.

# Check PHP version
php -version

# Output
PHP 8.0.5 (cli) (built: May 3 2021 11:30:57) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.5, Copyright (c) Zend Technologies
with Zend OPcache v8.0.5, Copyright (c), by Zend Technologies

Install PHP Dev

Install the PHP development package using the below-mentioned command.

sudo apt install php8.0-dev

Install Build Tools

Install the build tools using the below-mentioned command.

sudo apt -y install gcc make autoconf libc-dev pkg-config

Install MCrypt Dev

Install the MCrypt development package using the below-mentioned command.

sudo apt-get -y install libmcrypt-dev

Install MCrypt

Install the most recent version of MCrypt using the below-mentioned command.

# Install MCrypt
sudo pecl install mcrypt-1.0.4

# Output
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading mcrypt-1.0.4.tgz .
Starting to download mcrypt-1.0.4.tgz (27,056 bytes)
. done: 27,056 bytes
6 source files, building
running: phpize
Configuring for:
PHP Api Version: 20200930
Zend Module Api No: 20200930
Zend Extension Api No: 420200930
----
----

# Press enter on command prompt to complete installation
libmcrypt prefix? [autodetect] :

It will complete the installation and shows the success message as shown below.

Build process completed successfully
Installing '/usr/lib/php/20200930/mcrypt.so'
install ok: channel://pecl.php.net/mcrypt-1.0.4
configuration option "php_ini" is not set to php.ini location
You should add "extension=mcrypt.so" to php.ini

Configure PHP

Now configure the PHP by updating the php.ini file using the below-mentioned commands.

sudo bash -c "echo extension=/usr/lib/php/20200930/mcrypt.so > /etc/php/8.0/cli/conf.d/mcrypt.ini"
sudo bash -c "echo extension=/usr/lib/php/20200930/mcrypt.so > /etc/php/8.0/apache2/conf.d/mcrypt.ini"

At last, test your installation.

# Verify MCrypt
php -i | grep "mcrypt"

# Output
/etc/php/8.0/cli/conf.d/mcrypt.ini Registered Stream Filters => zlib.*, string.rot13, string.toupper, string.tolower, convert.*, consumed, dechunk, convert.iconv.*, mcrypt.*, mdecrypt.* mcrypt mcrypt support => enabled mcrypt_filter support => enabled mcrypt.algorithms_dir => no value => no value mcrypt.modes_dir => no value => no value

These are the steps required to install the MCrypt extension for the most recent version of PHP i.e. PHP 8. You can also refer How To Install MCrypt For PHP 7 On Ubuntu 20.04 LTS and How To Install MCrypt For PHP 7 On Ubuntu 18.04 LTS.

Summary

This tutorial provided the steps to install the most recent version of MCrypt for PHP 8. It also provided the resources to install PHP 8 on Ubuntu.

Источник

Оцените статью