Skip to content
Follow
Ubuntu Linux

How to Install mcrypt PHP Module on Ubuntu 24.04

Richard
Written by
Richard
Mar 14, 2025 Updated Jul 11, 2026 3 min read
How to Install mcrypt PHP Module on Ubuntu 24.04
How to Install mcrypt PHP Module on Ubuntu 24.04

You install the mcrypt PHP module on Ubuntu 24.04 by enabling the required package via third-party repositories.

The mcrypt PHP module offers critical encryption and decryption functions for securing sensitive data in your PHP applications. mcrypt supports various algorithms and modes, which were standard before PHP 7.1.

You might need the mcrypt PHP module for older PHP applications that still depend on its cryptographic features, even though mcrypt is now deprecated in favor of OpenSSL and libsodium for new development.

This guide provides the straightforward steps to get mcrypt running on your Ubuntu 24.04 system.

⚡ Quick Answer

Install the mcrypt PHP module on Ubuntu 24.04 by first installing necessary development packages with `sudo apt install gcc make autoconf libc-dev pkg-config libmcrypt-dev php-pear php-dev`. Then, run `sudo pecl install mcrypt` and enable the module by adding `extension=mcrypt.so` to your `php.ini` files.

Install PHP

📝Good to Know
If you use the mcrypt module, you must have PHP installed.

If you haven’t already done so, the post below shows you how to install PHP.

How to install PHP on Ubuntu

After installing PHP, continue below.

You need to install several important packages before you can install the mcrypt PHP module on Ubuntu 24.04. This includes development tools like gcc and make, along with libraries and PHP’s package manager, pear and pecl. Running the command `sudo apt install gcc make autoconf libc-dev pkg-config libmcrypt-dev php-pear php-dev` will prepare your system.

🐧Bash / Shell
sudo apt install gcc make autoconf libc-dev pkg-config libmcrypt-dev php-pear php-dev

Next, add and update the channel for PEAR and PECL using the command below.

🐧Bash / Shell
sudo pecl channel-update pecl.php.net
sudo pecl update-channels

After that, run the command below to build and install mcrypt.

🐧Bash / Shell
sudo pecl install mcrypt

Enable the mcrypt module

Once you’ve installed the mcrypt PHP module on Ubuntu, you must enable it for your web server or PHP applications to use. This involves adding a specific line to your PHP configuration files. The exact file to edit depends on whether you’re using Apache or Nginx with PHP-FPM, with paths like `/etc/php/8.3/apache2/` or `/etc/php/8.3/fpm/`.

For Apache:Run:

🐧Bash / Shell
sudo -s
echo extension=mcrypt.so > /etc/php/8.3/apache2/php.ini
echo extension=mcrypt.so > /etc/php/8.3/cli/php.ini

For Nginx:Run:

🐧Bash / Shell
sudo -s
echo extension=mcrypt.so > /etc/php/8.3/fpm/php.ini
echo extension=mcrypt.so > /etc/php/8.3/cli/php.ini

After adding the module to the PHP configuration file, restart the web server and PHP.

Test PHP

To test if the mcrypt PHP module is working correctly on Ubuntu after you’ve installed and enabled it, use a simple terminal command. Type `php -m | grep mcrypt` and press Enter. If the module is active, you’ll see `mcrypt` shown on your screen, confirming it’s ready to go.

🐘PHP
php -m | grep mcrypt

It should output mcrypt.

Or use the web.

PHP mcrypt module test
PHP mcrypt module test

That should do it!

Conclusion:

In summary, installing the mcrypt PHP module on Ubuntu is a straightforward process that can be crucial for supporting legacy applications. Here are the key takeaways:

  • Understanding mcrypt: mcrypt provides essential encryption and decryption functions for PHP developers but is deprecated in newer PHP versions.
  • Installation Prerequisites: Ensure PHP is installed before installing the mcrypt module.
  • Recommended Packages: Install necessary packages such as gcc, make, and libmcrypt-dev to successfully build the mcrypt module.
  • Enabling mcrypt: After installation, update the PHP configuration files for Apache and Nginx to enable the mcrypt extension.
  • Testing the Installation: Verify that mcrypt is active using the command line or checking through a web interface.

By following these installation steps, you ensure the mcrypt library integrates with your older PHP applications, allowing them to use encryption functions that mcrypt provides.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

📚 Related Tutorials

How to Manually Install OpenSSL on Ubuntu
Ubuntu Linux How to Manually Install OpenSSL on Ubuntu
How to Install GNOME Desktop on Ubuntu 24.04
Ubuntu Linux How to Install GNOME Desktop on Ubuntu 24.04
How to Install KDE Desktop on Ubuntu 24.04
Ubuntu Linux How to Install KDE Desktop on Ubuntu 24.04

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *