{"id":317,"date":"2014-06-04T10:05:42","date_gmt":"2014-06-04T15:05:42","guid":{"rendered":"http:\/\/www.popmartian.com\/tipsntricks\/?p=317"},"modified":"2014-06-04T10:16:47","modified_gmt":"2014-06-04T15:16:47","slug":"how-to-install-mcrypt-for-php-and-redhat-linux-6-or-oracle-linux-6","status":"publish","type":"post","link":"https:\/\/www.popmartian.com\/tipsntricks\/2014\/06\/04\/how-to-install-mcrypt-for-php-and-redhat-linux-6-or-oracle-linux-6\/","title":{"rendered":"HOW TO Install mcrypt  for PHP on RedHat Linux 6 and Oracle Linux 6"},"content":{"rendered":"<p>This tutorial shows you how to install libmcrypt and the companion PHP module under RedHat Linux 6 and Oracle Linux 6.<\/p>\n<p>By default, RHEL and OL do not provide mcrypt or libmcrypt packages for the 6.x release.  Subsequently, they don&#8217;t provide PHP5 mcrypt modules either.  Many PHP apps including PHPMyAdmin and Magento make use of the better crypto support of libmcrypt.<\/p>\n<p>So how do you install it?  You have to build it.<\/p>\n<p><em><strong>Part 1: Building libmcrypt<\/strong><\/em><\/p>\n<p><strong>Part 1, Step 1: Install your build environment<\/strong><br \/>\nlibmcrypt is written in C++ so you need a C++ compiler.<br \/>\n<code>sudo yum install gcc-c++.x86_64<\/code><br \/>\nThat will install the compiler and dependencies.<\/p>\n<p><strong>Part 1, Step 2: Get the software<\/strong><br \/>\nDownload it here: <a href=\"http:\/\/sourceforge.net\/projects\/mcrypt\/files\/\" title=\"http:\/\/sourceforge.net\/projects\/mcrypt\/files\/\">http:\/\/sourceforge.net\/projects\/mcrypt\/files\/<\/a><br \/>\nRemember, download <em>lib<\/em>mcrypt, not mcrypt.<\/p>\n<p><strong>Part 1, Step 3: Pick a location and unpack it<\/strong><br \/>\nMost people install software in to the default location, but I&#8217;m going to install in to somewhere that isn&#8217;t owned by root just to illustrate how to separate your custom app components from the OS.<br \/>\n<code>mkdir \/myappserver<br \/>\ncd \/myappserver<br \/>\ncp \/path\/to\/download\/libmcrypt-2.5.8.tar.bz2 \/myappserver\/<br \/>\nbunzip2 libmcrypt-2.5.8.tar.bz2<br \/>\ntar xf libmcrypt-2.5.8.tar<br \/>\nmv libmcrypt-2.5.8 libmcrypt-install<\/code><\/p>\n<p><strong>Part 1, Step 4: Build it!<\/strong><br \/>\n<code>cd libmcrypt-install<br \/>\n.\/configure --prefix=\/myappserver\/libmcrypt-2.5.8 --exec-prefix=\/myappserver\/libmcrypt-2.5.8 --disable-posix-threads<br \/>\nmake<br \/>\nmake install<br \/>\n<\/code><\/p>\n<p><strong>Part 1, Step 4: Make a Symlink<\/strong><br \/>\nIn order to make life easier for upgrades later, symlink libmcrypt to the version you built.  This will let you compile a new version later and simply move the symlink.  Anything else you build against this package will only need to know about the symlink.<br \/>\n<code>ln -s \/myappserver\/libmcrypt-2.5.8\/ \/myappserver\/libmcrypt<\/code><\/p>\n<p>You have successfully installed libmcrypt.  You can move it from server to server by simply copying \/myappserver\/libmcrypt-2.5.8\/ to any other machine.<\/p>\n<p><em><strong>Part 2: Building the PHP Module<\/strong><\/em><br \/>\nBuilding the PHP module can be done in one of two ways.<\/p>\n<ol>\n<li>Build your own PHP and copy the module to an existing PHP installation<\/li>\n<li>Build your own PHP and use it<\/li>\n<\/ol>\n<p>I&#8217;m not going to do a full tutorial on building PHP here (Option 2). Just note that the steps are the same as Option 1, but instead of copying the extention in to your PHP installation, compile PHP with all the modules you need, then install and use the PHP you built.<\/p>\n<p><strong>Option 1: Build your own PHP and copy the module to an existing PHP installation<\/strong><\/p>\n<p><strong>Part 2, Option 1, Step 1: Install your build environment<\/strong><br \/>\nPHP is written in C so you need a C compiler.<br \/>\n<code>sudo yum install gcc.x86_64<\/code><br \/>\nThat should give you everything you need to compile PHP.<\/p>\n<p><strong>Part 2, Option 1, Step 2: Get the software<\/strong><br \/>\n<em>MAKE SURE YOU DOWNLOAD THE PHP VERSION THAT MATCHES YOUR INSTALLATION<\/em><br \/>\nDownload it here: <a href=\"http:\/\/us3.php.net\/downloads.php\" title=\"http:\/\/us3.php.net\/downloads.php\">http:\/\/us3.php.net\/downloads.php<\/a><\/p>\n<p>For this tutorial, I used PHP 5.5.13<\/p>\n<p><strong>Part 2, Option 1, Step 3: Pick a location and unpack it<\/strong><br \/>\nI&#8217;m going to use a non-standard location since I&#8217;m just building the software.  I&#8217;m not going to use it from here.<br \/>\n<code>mkdir \/myappserver<br \/>\ncd \/myappserver<br \/>\ncp \/path\/to\/download\/php-5.5.13.tar.bz2 \/myappserver\/<br \/>\nbunzip2 php-5.5.13.tar.bz2<br \/>\ntar xf php-5.5.13.tar<br \/>\ncd php-5.5.13<\/code><\/p>\n<p><strong>Part 2, Option 1, Step 4: Build it!<\/strong><code><br \/>\n.\/configure --prefix=\/myappserver\/php-5.5.13 --exec-prefix=\/myappserver\/php-5.5.13 --with-mcrypt=\/myappserver\/libmcrypt<br \/>\nmake<\/code><\/p>\n<p>Note the <code>--with-mcrypt=\/myappserver\/libmcrypt<\/code> option.  This points to the symlink above.  If you need to upgrade libmcrypt later or rebuild the module for any reason, you don&#8217;t need to worry about what version of libmcrypt you have, just use the symlink!<\/p>\n<p>You should now be able to find your module in <code>\/myappserver\/php-5.5.13\/ext\/mcrypt<\/code><\/p>\n<p><strong>Part 2, Option 1, Step 5: Use it!<\/strong><\/p>\n<ul>\n<li>Copy the <code>mcrypt<\/code> directory above in to the <code>ext<\/code> directory in your PHP installation.<\/li>\n<li>Restart your Apache server<\/li>\n<\/ul>\n<p>Test it with a little PHP code:<br \/>\n<code>&lt;?php<br \/>\nextension_loaded('mcrypt') ? print 'Mcrypt is working' : print 'Mcrypt is not working';<br \/>\n?&gt;<\/code><\/p>\n<blockquote><p>Did you find this post useful or have questions or comments?  Please let  me know!<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows you how to install libmcrypt and the companion PHP module under RedHat Linux 6 and Oracle Linux 6. By default, RHEL and OL do not provide mcrypt or libmcrypt packages for the 6.x release. Subsequently, they don&#8217;t &hellip; <a href=\"https:\/\/www.popmartian.com\/tipsntricks\/2014\/06\/04\/how-to-install-mcrypt-for-php-and-redhat-linux-6-or-oracle-linux-6\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,25,3,67,27,66,65,11,9,42,56],"tags":[],"class_list":["post-317","post","type-post","status-publish","format-standard","hentry","category-apache","category-gcc","category-how-to-do-stuff","category-libmcrypt","category-linux","category-mcrypt","category-oracle-linux","category-php","category-programming","category-redhat","category-unix"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/posts\/317","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/comments?post=317"}],"version-history":[{"count":12,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/posts\/317\/revisions"}],"predecessor-version":[{"id":329,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/posts\/317\/revisions\/329"}],"wp:attachment":[{"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/media?parent=317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/categories?post=317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/tags?post=317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}