mcrypt php extension required

Как установить 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

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

После установки найдите куда установился файл 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=»), либо просто в конце файла, каким-нибудь редактором добавьте строку:

где вместо path_to_mcrypt напишите свой путь, который находили ранее.

Как установить 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.ini найдите где добавляются другие расширения (строки начинающиеся «extension=»), либо в конце файла, добавьте строку:

где вместо path_to_mcrypt напишите путь, куда распаковали dll-файл.

Вместо полного пути к библиотеки, можно так же в php.ini написать:

Проверить установку можно просто на одном из сайтов своего сервера выполнить php-код: phpinfo();. При этом, должна появиться секция mcrypt:

mcrypt php extension required. Смотреть фото mcrypt php extension required. Смотреть картинку mcrypt php extension required. Картинка про mcrypt php extension required. Фото mcrypt php extension required

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

Источник

Laravel requires the Mcrypt PHP extension

I am trying to use the migrate function in Laravel 4 on OSX. However, I am getting the following error:

As far as I understand, it’s already enabled (see the image below).

What is wrong, and how can I fix it?

mcrypt php extension required. Смотреть фото mcrypt php extension required. Смотреть картинку mcrypt php extension required. Картинка про mcrypt php extension required. Фото mcrypt php extension required

mcrypt php extension required. Смотреть фото mcrypt php extension required. Смотреть картинку mcrypt php extension required. Картинка про mcrypt php extension required. Фото mcrypt php extension required

22 Answers 22

Do you have MAMP installed?

Use which php in the terminal to see which version of PHP you are using.

Edited: First you should use command cd /Applications/MAMP/bin/php to check which PHP version from MAMP you are using and then replace with the PHP version above.

Then restart the terminal to see which PHP you are using now.

And it should be working now.

mcrypt php extension required. Смотреть фото mcrypt php extension required. Смотреть картинку mcrypt php extension required. Картинка про mcrypt php extension required. Фото mcrypt php extension required

mcrypt php extension required. Смотреть фото mcrypt php extension required. Смотреть картинку mcrypt php extension required. Картинка про mcrypt php extension required. Фото mcrypt php extension required

In this php.ini file you can enable the extension.

I have heard of people on OSX running in to problems due to the terminal pointing to the native PHP shipped with OSX. You should instead update your bash profile to include the actual path to your PHP. Something like this (I don’t actually use OSX so this might not be 100%):

Ubuntu

mcrypt php extension required. Смотреть фото mcrypt php extension required. Смотреть картинку mcrypt php extension required. Картинка про mcrypt php extension required. Фото mcrypt php extension required

To those that uses XAMPP 1.7.3 and Mac

/.bash_profile (or sudo vim

The reason for the mcrypt error is because your Mac uses its native php, you need to change it to the one xampp has.

P.S. I’d recommend using MAMP for Laravel 4 for Mac users, this issue will get resolved along with the php file info error without a sweat, and the php version of xampp is so outdated.

/.bash_profile, try checking the

For non MAMP or XAMPP users on OSX (with homebrew installed):

brew install homebrew/php/php56-mcrypt

did the trick for me. You don’t need to restart Apache since you need to use PHP just from the CLI.

In Ubuntu (PHP-FPM,Nginx)

After installing php5-mcrypt

you have to make a symlink to ini files in mods-available:

Getting Laravel working on Apache

PHP version : PHP 5.5.9

Ubuntu version : 14.04

getting artisan command working

(if you are having mcrypt error while using artisan command line tool)

i did a lot of trial and error so each time i run the php5enmod command before, i had error messages. but on fresh install there was no error messages. after this step i got artisan command working

fixing the browser error

(if you are having mcrypt error in browser when accessing local laravel index page)

add the following line under the dynamically compiled extensions section of php ini

For php-fpm installations on Ubuntu 14.04, the following worked for me :

sudo apt-get install php5-mcrypt

This will create mcrypt.ini file inside /etc/php5/mods-available/

sudo php5enmod mcrypt

will create a symlink in: /etc/php5/fpm/conf.d/

Just restart php-fpm services sudo service php5-fpm restart

For ubuntu try these steps if others are not working :

mcrypt php extension required. Смотреть фото mcrypt php extension required. Смотреть картинку mcrypt php extension required. Картинка про mcrypt php extension required. Фото mcrypt php extension required

mcrypt php extension required. Смотреть фото mcrypt php extension required. Смотреть картинку mcrypt php extension required. Картинка про mcrypt php extension required. Фото mcrypt php extension required

I resolve this issue, by finding configuration paths:

Then you can check your php modules via:

mcrypt php extension required. Смотреть фото mcrypt php extension required. Смотреть картинку mcrypt php extension required. Картинка про mcrypt php extension required. Фото mcrypt php extension required

Maybe you need install remi repo

mcrypt php extension required. Смотреть фото mcrypt php extension required. Смотреть картинку mcrypt php extension required. Картинка про mcrypt php extension required. Фото mcrypt php extension required

mcrypt php extension required. Смотреть фото mcrypt php extension required. Смотреть картинку mcrypt php extension required. Картинка про mcrypt php extension required. Фото mcrypt php extension required

I needed to make a symlink to my /etc/php5/conf.d/mcrypt.ini file in the following folders /etc/php5/apache2/conf.d/mcrypt.ini and /etc/php5/cli/conf.d/mcrypt.ini

Or even simple and more professional you can use Laravel Homestead.

Here is a link to official documentation: http://laravel.com/docs/5.0/homestead

I advice you to go with homestead because you will preinstall all of the following tools.

Expanding on @JetLaggy:

This did the trick for my particular setup. I had to adjust my PATH to reflect the updated version of PHP, but once I did, everything worked!

On OS X

Using MAMP

First, you should use command «cd /Applications/MAMP/bin/php» to check which php version from MAMP and take note of the version (eg, php5.6.7).

Once you know the version, you should edit the

Make sure that you replace php5.6.7 with the version of PHP that you have selected in MAMP.

Once the file has been saved, make sure that you close close your Terminal and open it again. Once that has been done, you will be using the PHP that ships with MAMP.

Copying and pasting those three lines into your terminal will correctly output the PHP version that has been selected inside the MAMP control panel.

Using Homebrew/MacPorts

Make sure that your path contains /usr/local/bin/ (Homebrew) or /opt/local/bin (MacPorts) if you are using PHP that comes with either of these two package managers.

Checking the PHP path with MacPorts

You can find the exact location of PHP using MacPorts with the following command:

Note that you should replace php70 with the version of PHP that you have installed.

Check the PHP path with Homebrew-php

Homebrew-php (https://github.com/Homebrew/homebrew-php) is a tap that has various different versions of PHP.

You can find the exact location of PHP using Homebrew with the following command:

Note that you should replace php56 with the version of PHP that you have installed.

Источник

How to enable php-Mcrypt extension in Laravel Homestead

I am trying to get an old Laravel 4.1.x app up and running again so that it can be modernized. This requires an environment with PHP 5.6 and the Mcrypt extension. I have installed Homestead 9.0.3 (the latest stable version). Within the VM, I have set the PHP version to 5.6

I have then installed the php-mcrypt extension

I am now able to create a new Laravel 4.1.x project, which is a process that requires Mcrypt to complete, so we’re certainly getting somewhere:

However, when I browse to the webpage for myAppName, I see the message:

Mcrypt PHP extension required.

I have also tried steps that are usually recommended for this problem, ie:

But I still get the same message in the browser.

What step have I missed?

2 Answers 2

With homestead v9 you should be up and running with php5.6 out of the box as stated in here, but unfortunately it is not your case, and I understand that.

Old packages were not installed by default (php5.6-mcrypt), as you mentioned and they should be added by hand via: sudo apt-get install php5.6-mcrypt

After that all packages are ready, up and working, especially php5.6-mcrypt.

The root of your problem is in multiple site definitions under your homestead.yaml. Most probably some of them are overlapping and your nginx is referring to the wrong resource/site_definition, and wrong paths.

Therefore you might think some strange php versions or routes are run/executed.

All of your problems should be gone after that.

In my installation Homestead v9 is running with php5.6 on laravel 4.1 without any problems.

Источник

How to Install the PHP mcrypt Extension

The mcrypt extension is an interface to the mcrypt cryptography library. This extension is useful for allowing PHP code using mcrypt to run on PHP 7.2+.

The mcrypt extension is included in PHP 5.4 through PHP 7.1. It was removed from PHP 7.2 and moved to an unofficial PECL extension because the mcrypt library is no longer maintained.

For PHP 7.2+, PHP instead uses libsodium as a cryptography library. ServerPilot builds PHP 7.2+ with the official libsodium extension. New PHP code should be written to use libsodium rather than mcrypt.

Installing mcrypt on PHP 5, PHP 7.0, and PHP 7.1

You do not need to install the mcrypt extension on PHP 5, 7.0, or 7.1. ServerPilot builds these PHP versions with the mcrypt extension so it is always available.

Installing mcrypt on PHP 7.2, 7.3, or 7.4

To install this extension on PHP 7.2 through 7.4, run the following commands as your server’s root user:

When you are shown the prompt

Press Enter to autodetect.

Once installed, create a configuration file for the extension and restart PHP by running the following commands as root:

Verifying mcrypt Is Installed

You can check that the extension was installed with this command:

The output will look like this:

Uninstalling the Mcrypt Extension

To uninstall this extension, as root run the commands:

Источник

mcrypt is deprecated, what is the alternative?

The mcrypt-extension is deprecated will be removed in PHP 7.2 according to the comment posted here. So I am looking for an alternative way to encrypt passwords.

Right now I am using something like

I need your opinion for the best/strongest way to encrypt passwords, the encrypted password should of course supported by PHP 7.xx and should also be decryptable because my customers do want to have an option to ‘recover’ their passwords without generating a new one.

10 Answers 10

It’s best practice to hash passwords so they are not decryptable. This makes things slightly more difficult for attackers that may have gained access to your database or files.

If you must encrypt your data and have it decryptable, a guide to secure encryption/decryption is available at https://paragonie.com/white-paper/2015-secure-php-data-encryption. To summarize that link:

As suggested by @rqLizard, you can use openssl_encrypt / openssl_decrypt PHP functions instead which provides a much better alternative to implement AES (The Advanced Encryption Standard) also known as Rijndael encryption.

OpenSSL also uses PKCS7 padding with CBC mode rather than mcrypt’s NULL byte padding. Thus, mcrypt is more likely to make your code vulnerable to padding oracle attacks than OpenSSL.

Finally, if you are not authenticating your ciphertexts (Encrypt Then MAC), you’re doing it wrong.

Code examples

Example #1

AES Authenticated Encryption in GCM mode example for PHP 7.1+

Example #2

AES Authenticated Encryption example for PHP 5.6+

Example #3

Based on above examples, I’ve changed the following code which aims at encrypting user’s session id:

To clarify, above change is not a true conversion since the two encryption uses a different block size and a different encrypted data. Additionally, the default padding is different, MCRYPT_RIJNDAEL only supports non-standard null padding. @zaph

Additional notes (from the @zaph’s comments):

Encryption with different block sizes for Rijndael produces different encrypted data.

For example, MCRYPT_RIJNDAEL_256 (not equivalent to AES-256 ) defines a different variant of the Rijndael block cipher with size of 256-bits and a key size based on the passed in key, where aes-256-cbc is Rijndael with a block size of 128-bits with a key size of 256-bits. Therefore they’re using different block sizes which produces entirely different encrypted data as mcrypt uses the number to specify the block size, where OpenSSL used the number to specify the key size (AES only has one block size of 128-bits). So basically AES is Rijndael with a block size of 128-bits and key sizes of 128, 192 and 256 bits. Therefore it’s better to use AES, which is called Rijndael 128 in OpenSSL.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *