Wednesday, January 04, 2017

Fatal Error Call to undefined function mcrypt_encrypt() .php on line 13

Call to undefined function mcrypt_encrypt() in file.php on line

Recently, we were trying to port a php application from the test server to the live Centos server and encountered this unusual undefined function mcrypt_encrypt error.

When porting from my local server to the live server for testing, the php page was not loading and returned an Error 500 or Internal Server Error.

Analyse Apache error logs

Apparently, the error logs of the Apache web server had to be analyzed. 

So, as a first step, we tried to analyse the apache error logs to shortlist the reasons. On closer look, the following line seemed to hold the key to the problem.

PHP Fatal error:  Call to undefined function mcrypt_encrypt() in /path/to/myAppFolder/myFile.php on line 13

The reason for undefined function mcrypt_encrypt() problem

Missing php-mcrypt module

The issue seems to be related to a missing module in the Centos server. The php program was using the php-mcrypt module and it was not yet installed on the server yet.

Install php-mcrypt and restart Apache

The next logical step is to setup thephp-mcrypt module. So, we installed the php-mcrypt module using the below command

sudo yum install php-mcrypt

Once the php-mcrypt was installed, we need to restart the Web Server. As a final step, we restarted the Apache Web Server using the following command.

sudo systemctl restart httpd

After this, we tested the web application to see if the undefined function mcrypt_encrypt problem persists. To our relief, calling the php program did not generate error now. 

Problem of Fatal Error Call to undefined function mcrypt_encrypt() php 7 SOLVED.

Post a Comment

Why should I not take revenge?

This is what we do and have been doing since we have known man. Revenge seems to be a natural response to injustice that seems to target us... Registered & Protected DWYE-NHTO-NBNH-7FFM