{"id":14048,"date":"2023-04-20T07:32:06","date_gmt":"2023-04-20T07:32:06","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=14048"},"modified":"2023-09-28T07:25:15","modified_gmt":"2023-09-28T07:25:15","slug":"how-to-install-mcrypt-extension-on-ubuntu","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-install-mcrypt-extension-on-ubuntu\/","title":{"rendered":"How to Install mcrypt extension on Ubuntu"},"content":{"rendered":"<p>The mcrypt extension is a popular encryption library for PHP that provides support for various encryption algorithms. However, since PHP 7.2, the mcrypt extension has been deprecated and removed from the PHP core. If you need to use mcrypt with your PHP applications on an <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-ubuntu-beginners-guide-ubuntu-linux-distro\/\">Ubuntu<\/a> system, you can still install and enable it manually.<\/p>\n<p>In this step-by-step guide, we will show you how to install the mcrypt extension on Ubuntu for PHP versions 7.2 and above. By following these steps, you&#8217;ll be able to use mcrypt in your PHP projects, despite its deprecation.<\/p>\n<h2>Step 1: Install Required Dependencies<\/h2>\n<p>First, update your package repositories and install the required dependencies for building the mcrypt extension.<\/p>\n<pre>\r\nsudo apt-get update\r\nsudo apt-get install -y php-dev libmcrypt-dev gcc make autoconf libc-dev pkg-config\r\n<\/pre>\n<h2>Step 2: Install the PHP mcrypt Extension<\/h2>\n<p>Now that you have the required dependencies, you can install the mcrypt extension using the &#8220;pecl&#8221; command:<\/p>\n<pre>\r\nsudo pecl install mcrypt-1.0.4\r\n<\/pre>\n<p>The version number (1.0.4) may change over time, so make sure to check the latest version on the PECL repository before running the command.<\/p>\n<h2>Step 3: Enable the mcrypt Extension<\/h2>\n<p>After the installation is complete, you need to enable the mcrypt extension in your PHP configuration. To do this, create a new configuration file and add the necessary line to load the extension:<\/p>\n<pre>\r\necho \"extension=mcrypt.so\" | sudo tee \/etc\/php\/7.2\/mods-available\/mcrypt.ini\r\n<\/pre>\n<p>Replace &#8220;7.2&#8221; with the PHP version you are using on your system.<\/p>\n<p>Next, enable the extension using the &#8220;phpenmod&#8221; command:<\/p>\n<pre>\r\nsudo phpenmod mcrypt\r\n<\/pre>\n<h2>Step 4: Restart Your Web Server<\/h2>\n<p>To finalize the installation, restart your web server (Apache or Nginx) to load the mcrypt extension:<\/p>\n<pre>\r\nsudo systemctl restart apache2\r\n<\/pre>\n<p>Or, if you are using Nginx with PHP-FPM:<\/p>\n<pre>\r\nsudo systemctl restart php7.2-fpm\r\nsudo systemctl restart nginx\r\n<\/pre>\n<p>Replace &#8220;7.2&#8221; with the PHP version you are using on your system.<\/p>\n<h2>Commands Mentioned:<\/h2>\n<ul>\n<li><span class=\"fw-bold\">apt-get update<\/span> &#8211; Update package repositories<\/li>\n<li><span class=\"fw-bold\">apt-get install<\/span> &#8211; Install specified packages and their dependencies<\/li>\n<li><span class=\"fw-bold\">pecl install<\/span> &#8211; Install a PECL package<\/li>\n<li><span class=\"fw-bold\">echo<\/span> &#8211; Print a string to the terminal or a file<\/li>\n<li><span class=\"fw-bold\">tee<\/span> &#8211; Redirect output to multiple destinations<\/li>\n<li><span class=\"fw-bold\">phpenmod<\/span> &#8211; Enable a PHP module<\/li>\n<li><span class=\"fw-bold\">systemctl restart<\/span> &#8211; Restart a system service<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>In this guide, we&#8217;ve demonstrated how to install the mcrypt extension on an Ubuntu system running PHP 7.2 or above. Despite its deprecation, you can still use the mcrypt extension for your PHP projects if it&#8217;s necessary for your specific use case.<\/p>\n<p>It&#8217;s important to note that the mcrypt extension is deprecated, and it&#8217;s recommended to use alternative encryption libraries, such as <a href=\"https:\/\/webhostinggeeks.com\/blog\/openssl-explained-in-simple-terms\/\">OpenSSL<\/a> or libsodium, for new projects or when updating existing ones. These modern libraries offer better security and are actively maintained, reducing the risks associated with using deprecated or unmaintained libraries.<\/p>\n<p>Nevertheless, if you have a legacy PHP application that requires the mcrypt extension, this guide provides a reliable method for installing and enabling it on your Ubuntu system.<\/p>\n<p>Remember to keep your system and software up-to-date, including any security patches for the mcrypt extension, to minimize potential vulnerabilities. Moreover, consider migrating your projects to use more modern and secure encryption libraries whenever possible, to ensure your applications remain secure and compatible with the latest PHP versions.<\/p>\n<p>We hope this guide has helped you successfully install the mcrypt extension on your Ubuntu system. If you have any questions, comments, or suggestions for improvement, please feel free to share your thoughts in the comments section below. Your feedback is invaluable to us, and it helps us create better and more informative content for our users.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The mcrypt extension is a popular encryption library for PHP that provides support for various encryption algorithms. However, since PHP 7.2, the mcrypt extension has been deprecated and removed from&#8230;<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[996],"tags":[1975,1567,1646,1653],"class_list":["post-14048","post","type-post","status-publish","format-standard","hentry","category-linux","tag-install","tag-mcrypt","tag-php","tag-php-mcrypt"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/14048","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=14048"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/14048\/revisions"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=14048"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=14048"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=14048"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}