How to install mcrypt on PHP 7.3.3 ubuntu

How to install mcrypt on PHP 7.3.3 ubuntu

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

The Version Lockout Problem with Mcrypt on PHP 7.3.3

Attempting to install the mcrypt extension on a modern Ubuntu system running PHP 7.3.3 often leads to an immediate failure when using PECL. You will likely encounter an error message stating that pecl/mcrypt requires PHP versions between 7.2.0 and 7.3.0, explicitly excluding 7.3.0. If you are on 7.3.3, the installation script rejects your environment before it even begins downloading or compiling the library.

This restriction exists because the upstream maintainers of the mcrypt PECL package dropped support for PHP 7.3 entirely. The underlying reason is a divergence between the extension's build requirements and the changes introduced in the PHP 7.3 release cycle, specifically regarding how libraries like OpenSSL are integrated and linked against the standard library. Since you cannot patch the upstream source code easily without breaking compatibility with future PHP versions, you must bypass the PECL package manager entirely and compile the library directly from source.

This approach requires a specific sequence of dependencies that differ slightly from the standard Ubuntu repositories because the official libmcrypt-dev package often conflicts with the modern libgmp10 or lacks the necessary headers for PHP 7.3. You need to ensure your system has the compiler toolchain ready before attempting any installation. Run the following commands to install the essential build tools and development libraries:

sudo apt-get update
sudo apt-get -y install gcc make autoconf libc-dev pkg-config php7.3-dev

Note that we are explicitly targeting php7.3-dev rather than the generic php-dev. Using the correct version-specific dev package ensures that the compiler links against the correct headers for your specific PHP build, preventing ABI incompatibilities later on.

Once the toolchain is prepared, you must handle the source code manually. First, download the latest stable release of the mcrypt extension from GitHub or the official PECL site, ensuring you get a version that claims compatibility with PHP 7.3 despite the upstream package restrictions. Extract the archive into a temporary directory:

cd /tmp
wget https://github.com/jhuckaby/mcrypt/archive/master.zip
unzip master.zip
cd mcrypt-master/

The critical step here is configuring the build process to point directly at your PHP 7.3 installation. If you are running a system-managed PHP where phpize points to 8.x or another version, you must explicitly tell the extension compiler where to find the 7.3 headers and libraries. Use the --with-php-config flag to specify the path to the correct binary:

phpize --with-php-config=$(which php) configure --with-php-config=/usr/bin/php7.3

Replace /usr/bin/php7.3 with the actual path to your PHP executable if it differs, which you can verify using which php. This ensures that when the extension is built, it compiles against the exact binary interface of your running interpreter.

After configuration, compile and install the extension:

make
sudo make install

The resulting .so file should be placed in your PHP extensions directory, typically /usr/lib/php/20180904/ or a similar path depending on your libtool version. Verify its location using php -i | grep mcrypt.

You must then manually edit your php.ini file to include the line extension=mcrypt.so. Be aware that if you are running PHP as a system service via systemd, you may need to ensure this change is persisted in /etc/php/7.3/mods-available/mcrypt.ini or included in your main configuration file via an .include directive.

Restart your web server or PHP-FPM pool and verify that the startup warning regarding mcrypt.so has vanished. This manual compilation method bypasses the version lockout enforced by the PECL repository, allowing legacy applications like PrestaShop to function on supported Ubuntu LTS versions while adhering to modern security standards for compiling extensions from source.

For teams managing large-scale deployments where maintaining multiple PHP versions is difficult, consider whether mcrypt is truly necessary. Modern cryptography libraries often recommend migrating away from deprecated algorithms found in older mcrypt implementations toward more robust alternatives like the OpenSSL functions or libsodium, though that migration path depends on the specific legacy codebase you are supporting.

Our network