Report this

What is the reason for this report?

MCrypt extension required to run Craft CMS

Posted on August 2, 2020

I’m getting the following error on https://ginaphillips.net/:

Can’t run Craft CMS :(

Your server doesn’t meet the following requirements to run Craft CMS:

    The Mcrypt extension is required.

Please talk to your host/IT department about upgrading your server.

I was on PHP 7.3, have upgraded to PHP 7.4, but still getting the same error.

How do I fix this?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there @drr1000,

You would need to manually install MCrypt using pecl. To install pecl you need to install the PHP Extension and Application Repository or PEAR for short:

  1. sudo apt install php-pear

You might also have to install the PHP Dev tools:

  1. sudo apt install php-dev

Then we would want to go ahead and install this package here. To do that, just run:

  1. sudo pecl install mcrypt-1.0.3

Finally, make sure that you enable the new PHP extension by adding the following line to your php.ini:

extension=mcrypt.so

If you are running PHP FPM make sure to restart it after the change to your php.ini file.

Hope that this helps. Regards, Bobby

Hey @danielzhang,

The mcrypt library was deprecated in PHP 7.1, and it was removed entirely in PHP 7.2. If you’re using PHP 7.3 or a later version, you can’t enable mcrypt in the same way as before. Instead, you’ll need to use a different method.

However, if you still need to use mcrypt due to some legacy code that you can’t update to use a more modern encryption method, there’s a PECL extension available that brings back mcrypt to PHP 7.3 or later versions.

In this example, we’ll be using 8.1

Install prerequisites

Before you install the mcrypt extension, you’ll need to make sure that you have some necessary packages installed on your system.

On Ubuntu:

  1. sudo apt-get update
  2. sudo apt-get install php-pear php8.1-dev gcc make autoconf libc-dev pkg-config libmcrypt-dev php-pear

On CentOS:

  1. sudo yum install php-pear php-devel gcc make autoconf libc-dev pkg-config libmcrypt-devel php-pear

Install mcrypt extension

After you’ve installed these packages, you can install the mcrypt extension itself:

  1. sudo pecl install mcrypt-1.0.3

During the installation, you may be asked for the libmcrypt prefix. If you are, press enter to skip.

Configure PHP to use the mcrypt extension

After the installation is complete, you’ll need to tell PHP to use the mcrypt extension. To do this, you’ll need to modify your php.ini file.

First, you’ll need to find it. You can do this by using the following command:

  1. php --ini

Look for the line that says “Loaded Configuration File”. This will tell you where your php.ini file is located.

Open this file with your favorite text editor (like nano or vim). For example:

  1. sudo nano /etc/php/8.1/cli/php.ini

Add the following line to the file:

  1. extension=mcrypt.so

Restart your web server

Finally, you’ll need to restart your web server for the changes to take effect.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.