Program Club

치명적인 오류 : 정의되지 않은 함수 mcrypt_encrypt () 호출

proclub 2020. 11. 25. 21:25
반응형

치명적인 오류 : 정의되지 않은 함수 mcrypt_encrypt () 호출


참고 : MCrypt 지원에 의존하는 라이브러리는 수년 동안 업데이트되지 않았으며 MCrypt는 더 이상 실행 가능하거나 안전한 데이터 암호화 방법으로 간주되지 않아야합니다. 또한 MCrypt는 PHP 5에서 더 이상 사용되지 않으며 PHP 7에서 완전히 제거되었습니다. MCrypt를 실행하는 코드가있는 경우보다 현대적인 암호화 라이브러리를 사용하도록 리팩토링해야합니다.


이 오류 메시지 : (Call to undefined function mcrypt_encrypt() )아래 코드를 실행할 때 표시되는 이유를 아는 사람이 있습니까?

이 코드가 작동하기 전에 수행해야하는 PHP의 일부 단계가 누락 되었습니까?

$key = 'password to (en/de)crypt';
$string = 'string to be encrypted';

$test = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key),
            $string, MCRYPT_MODE_CBC, md5(md5($key)));

PHP 버전 5.2.8에서 나를 위해 일한 것은을 제거하여 확장 을 열고 php.ini허용 하는 것입니다.php_mcrypt.dll;

;extension=php_mcrypt.dll ...에 extension=php_mcrypt.dll


최근에 우분투 14.04로 업데이트 한 경우이 문제에 대한 해결책은 다음과 같습니다.

$ sudo mv /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/
$ sudo php5enmod mcrypt
$ sudo service apache2 restart

Windows 용

;extension=php_mcrypt.dll to extension=php_mcrypt.dll 
 then restart your apache server

Redhat 용

sudo yum install php55-mcrypt //if php5.5
sudo yum install php-mcrypt //if less than 5.4
sudo service httpd restart //if apache 2.4
sudo /etc/init.d/httpd restart //if apache 2.2 or less

Ubuntu의 경우

sudo apt-get install php5-mcrypt
sudo service apache2 restart //if server not reloaded automatically 

그래도 작동이 안되는?

sudo php5enmod mcrypt && sudo service apache2 restart


mcrypt 라이브러리가 설치되어 있지 않습니다.

자세한 내용은 http://www.php.net/manual/en/mcrypt.setup.php 를 참조하십시오.

공유 호스팅을 사용중인 경우 공급자에게 설치를 요청할 수 있습니다.


OSX에서는 homebrew를 통해 mcrypt를 쉽게 설치할 수 있습니다.

brew install php54-mcrypt --without-homebrew-php

그런 다음이 줄을 /etc/php.ini에 추가합니다.

extension="/usr/local/Cellar/php54-mcrypt/5.4.24/mcrypt.so"

PHP 7.2 이상을 사용하는 경우 :

이 함수는 PHP 7.1.0에서 지원 중단되었으며 PHP 7.2.0에서 삭제되었습니다.

출처 : http://php.net/manual/en/function.mcrypt-encrypt.php

따라서 PHP 코드를 교체하고 mcrypt가없는 솔루션을 찾아야합니다.

또는 방금 알았는데 PHP 7.2.0에서 여전히 mcrypt를 사용할 수 있지만 PHP 확장 커뮤니티 라이브러리로 설치해야합니다. ( https://pecl.php.net/ )

Debian / Ubuntu Linux 배포판에서 :

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

그때:

sudo pecl install mcrypt-1.0.1

출처 : https://www.techrepublic.com/article/how-to-install-mcrypt-for-php-7-2/


우분투에서 나는 문제가 있었고 그것을 해결했습니다.

$ sudo apt-get install php5-mcrypt
$ sudo service apache2 reload

우분투 14.10 :

mcrypt 모듈 설치

sudo apt install php5-mcrypt

apache2에서 모듈 mcrypt 활성화

sudo a2enmod mcrypt

모듈 구성 다시로드

sudo service apache2 restart

Linux Mint 17.1 Rebecca에서-정의되지 않은 함수 mcrypt_create_iv 호출 ...

php.ini에 다음 줄을 추가하여 해결되었습니다.

extension=mcrypt.so

그 후

service apache2 restart

해결 ...


누락 된 mcrypt의 PHP 7 버전에 대해 동일한 문제가 발생했습니다 .

이것은 나를 위해 일했습니다.

sudo apt-get update
sudo apt-get install mcrypt php7.0-mcrypt
sudo apt-get upgrade
sudo service apache2 restart (if needed)

mcrypt가 활성화되어 있습니까? phpinfo()그것이 있는지 확인하는 데 사용할 수 있습니다 .


One more thing: if you are serving PHP via a web server such as Apache, try restarting the web server. This will "reset" any PHP modules that might be present, activating the new configuration.


Assuming you are using debian linux (I'm using Linux mint 12, problem was on Ubuntu 12.04.1 LTS server I ssh'ed into.)

I suggest taking @dkamins advice and making sure you have mcrypt installed and active on your php5 install. Use "sudo apt-get install php5-mcrypt" to install. My notes below.

Using PHP version PHP Version 5.3.10-1ubuntu3.4, if you open phpinfo() as suggested by @John Conde, which you do by creating test file on web server (e.g. create status page testphp.php with just the contents "" anywhere accessible on the server via browser)

I found no presence of enabled or disabled status on the status page when opened in browser. When I then opened the php.ini file, mentioned by @Anthony Forloney, thinking to uncomment ;extension=php_mcrypt.dll to extension=php_mcrypt.dll

I toggled that back and forth and restarted Apache (I'm running Apache2 and you can restart in my setup with sudo /etc/init.d/apache2 restart or when you are in that directory just sudo restart I believe) with change and without change but all no go. I took @dkamins advice and went to install the package with "sudo apt-get install php5-mcrypt" and then restarted apache as above. Then my error was gone and my application worked fine.


If you are using php5-fpm do remeber to restart it, after installing mcrypt

service php5-fpm restart


If you using ubuntu 14.04 here is the fix to this problem:

First check php5-mcryp is already installed apt-get install php5-mcrypt

If installed, just run this two command or install and run this two command

$ sudo php5enmod mcrypt
$ sudo service apache2 restart

I hope it will work.


for Linux based (Fedora)

yum -y install php-mcrypt

Enable the module by adding: 'extension=mcrypt.so' to PHP.ini. (/etc/php.ini)

systemctl restart httpd.service

Done!


For me it helped to uninstall mcrypt with:

sudo apt-get purge php5-mcrypt

and simply reinstall it:

sudo apt-get install php5-mcrypt

and dont forget to restart apache as described above.

Dont know why and how this was different in my case (using a vm with provisioned php55), but maybe this will help someone else. I also had this problem with some other modules like xcache...


Check and install php5-mcrypt:

sudo apt-get install php5-mcrypt

참고URL : https://stackoverflow.com/questions/2604435/fatal-error-call-to-undefined-function-mcrypt-encrypt

반응형