Skip to content
Follow
Ubuntu Linux

How to Install mcrypt PHP Module on Ubuntu 24.04

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

Installing the mcrypt PHP module on Ubuntu 24.04 adds encryption and decryption tools for older website code that still relies on this discontinued library. PHP removed mcrypt from its core software back in version 7.2, meaning modern servers running PHP 8.x no longer include it by default.

Advertisement

Legacy apps and older websites need this module to process secure data without breaking. You can add mcrypt to Ubuntu 24.04 using a trusted software repository (an archive of installable software packages) maintained by Ondřej Surý, which bridges the gap between modern PHP versions and outdated code.

⚡ 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.

Advertisement

Install PHP

Make sure PHP is already installed on your system before you start. Reviewing the guide ‘How to install PHP on Ubuntu’ helps handle that setup beforehand. Continuing with the following instructions happens once PHP runs successfully.

How to install PHP on Ubuntu

Proceed below after completing the PHP setup.

You need to install the required development tools and package repositories before you can install mcrypt PHP Ubuntu. Run the sudo apt install gcc make autoconf libc-dev pkg-config libmcrypt-dev php-pear php-dev command in your terminal to set up all the necessary compilers, development headers, and PEAR packages on your Ubuntu 24.04 system.

Advertisement
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.

sudo pecl channel-update pecl.php.net
sudo pecl update-channels

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

sudo pecl install mcrypt

Enable the mcrypt module

You must enable the mcrypt module in your PHP configuration files so your web server can use it. The correct configuration file depends on whether you use Apache or Nginx with PHP-FPM, and you need to add the extension line to the right folder for your specific server setup to make it active.

For Apache, add the extension to the configuration file using `sudo nano /etc/php/8.3/apache2/php.ini`.

Advertisement
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 with PHP-FPM, open the corresponding file located at `sudo nano /etc/php/8.3/fpm/php.ini` instead.

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

Web servers and PHP services require a restart following configuration updates.

Test PHP

You can test PHP to confirm that the install mcrypt PHP Ubuntu process worked correctly. Run the php -m | grep mcrypt command in your terminal to check if the module appears in your active module list, or use a browser-based test page to verify it works with your web server.

php -m | grep mcrypt

Output should display mcrypt.

Advertisement

Browser testing offers an alternative verification method.

PHP mcrypt module test
PHP mcrypt module test

Configuration finishes here.

Test PHP using the command line or a web interface to ensure mcrypt is active and working properly.

  • 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.

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.

Advertisement

📚 Related Tutorials

How to Install Apache on Ubuntu Linux
Ubuntu Linux How to Install Apache on Ubuntu Linux
How to Install Nginx on Ubuntu Linux
Ubuntu Linux How to Install Nginx on Ubuntu Linux
How to Install Ubuntu Linux
Ubuntu Linux How to Install Ubuntu Linux
How to Install PHP on Ubuntu Linux
Ubuntu Linux How to Install PHP on Ubuntu Linux

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

Leave a Comment

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