{"id":17268,"date":"2026-01-29T12:18:47","date_gmt":"2026-01-29T06:48:47","guid":{"rendered":"https:\/\/www.skynats.com\/?p=17268"},"modified":"2026-01-29T12:20:29","modified_gmt":"2026-01-29T06:50:29","slug":"how-to-install-and-enable-php-mcrypt-extension-on-ubuntu","status":"publish","type":"post","link":"https:\/\/www.skynats.com\/blog\/how-to-install-and-enable-php-mcrypt-extension-on-ubuntu\/","title":{"rendered":"How to Install and Enable PHP mcrypt Extension on Ubuntu"},"content":{"rendered":"\n<h2 class=\"wp-block-heading has-small-font-size\" id=\"h-introduction\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The mcrypt PHP extension was once widely used for encryption and decryption in PHP applications. Although it has been deprecated in newer PHP versions, some legacy applications still depend on it to function correctly. In such cases, Install PHP mcrypt extension on Ubuntu becomes necessary to maintain compatibility.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this blog, we\u2019ll walk through the steps to install and activate the PHP mcrypt extension on an <a href=\"https:\/\/ubuntu.com\/\" type=\"link\" id=\"https:\/\/ubuntu.com\/\" target=\"_blank\" rel=\"noopener\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-secondary-color\">Ubuntu<\/mark><\/a> server, following standard and reliable practices.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-small-font-size\" id=\"h-why-mcrypt-is-needed\">Why mcrypt Is Needed<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Some older PHP frameworks, CMS platforms, or custom applications rely on mcrypt for cryptographic operations. When migrating servers or upgrading PHP versions, these applications may throw errors like:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Call to undefined function mcrypt_encrypt()<\/li>\n\n\n\n<li>mcrypt extension not loaded<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Installing mcrypt resolves these compatibility issues.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-small-font-size\" id=\"h-installing-php-mcrypt-on-ubuntu\">Installing PHP mcrypt on Ubuntu<\/h2>\n\n\n\n<h2 class=\"wp-block-heading has-small-font-size\" id=\"h-step-1-update-the-system\"><strong>Step 1:<\/strong> Update the System<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before installing any packages, make sure your system repositories are up to date:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-small-font-size\" id=\"h-step-2-install-required-dependencies\"><strong>Step 2:<\/strong> Install Required Dependencies<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Install the necessary development libraries:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install libmcrypt-dev php-dev<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-small-font-size\" id=\"h-step-3-install-mcrypt-using-pecl\"><strong>Step 3:<\/strong> Install mcrypt Using PECL<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Since mcrypt is no longer bundled with PHP, it must be installed via PECL:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo pecl install mcrypt<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">During installation, press Enter to accept default values when prompted.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Enable the mcrypt Extension<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once installed, enable the extension by creating the configuration file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"extension=mcrypt.so\" | sudo tee \/etc\/php\/8.1\/mods-available\/mcrypt.ini<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Make sure to replace 8.1 with your actual PHP version.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then enable it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo phpenmod mcrypt<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Restart Web Services<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Restart your web server to apply changes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart apache2<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">or, if using PHP-FPM:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart php8.1-fpm<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Verify Installation<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Confirm that mcrypt is enabled:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php -m | grep mcrypt<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Or check via a phpinfo() page in your browser vc<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-small-font-size\">Conclusion<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Although mcrypt is deprecated, it remains essential for running certain legacy PHP applications. By installing it via PECL and enabling it correctly on Ubuntu, you can ensure backward compatibility without breaking existing functionality.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For new projects, it\u2019s strongly recommended to migrate to modern encryption libraries like OpenSSL or Sodium, which are actively maintained and more secure.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you still face issues or want expert help to Install PHP mcrypt extension on Ubuntu, Skynats\u2019 professional <a href=\"https:\/\/www.skynats.com\/server-management\/\" type=\"link\" id=\"https:\/\/www.skynats.com\/blog\/server-management\/\">server management services<\/a> are here to assist. Our certified engineers handle PHP configuration, Linux troubleshooting, and performance optimization so you can focus on your business without server headaches. Contact Skynats today for reliable, 24\/7 server support.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction The mcrypt PHP extension was once widely used for encryption and decryption in PHP applications. Although it has been deprecated in newer PHP versions, some legacy applications still depend on it to function correctly. In such cases, Install PHP mcrypt extension on Ubuntu becomes necessary to maintain compatibility. In this blog, we\u2019ll walk through [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[1224,1225,1223,1226,1222,1227,1228,1229,236],"class_list":["post-17268","post","type-post","status-publish","format-standard","hentry","category-blog","tag-install-php","tag-mcrypt-extension","tag-mcrypt-php-extension","tag-php-frameworks","tag-php-mcrypt","tag-php-versions","tag-server-managemnet-services","tag-sever-management-services","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/17268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/comments?post=17268"}],"version-history":[{"count":2,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/17268\/revisions"}],"predecessor-version":[{"id":17271,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/17268\/revisions\/17271"}],"wp:attachment":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/media?parent=17268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/categories?post=17268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/tags?post=17268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}