Yay, CentOS 6 still doesn’t by default include mcrypt in it’s distribution on repositories.

There is hope, EPEL to the rescue again:

rpm -ivh http://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum update

You should see EPEL listed as the repos, then:

yum install php-mcrypt

Also a few of you have mentioned you need to restart Apache. To do this:

service httpd restart

Done.

If you want to do the same for CentOS 7 then simply use this instead:

rpm -ivh http://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
yum update

**Please note the above download is for CentOS 6 x86_64**

UPDATE 12/02/2013: Updated to Latest Link for EPEL 6.8
UPDATE 05/01/2015: Added the link for CentOS 7/EPEL 7.5

Hey There!

Thanks for stopping by, this is by far one of my most popular ever posts on my site, while your here why not have a look at some of my other articles. Or even better get in touch to find out how I might be able to help on your next project!

digital-ocean

 Tagged with: , ,

47 thoughts on “PHP Mcrypt on CentOS 6

  • Pls help me width nginx

     Reply

    • You’re going to have to give me a little more than just that?!

       Reply

      • I use nginx, centos 6
        but when installed opencart, Mcrypt inactive

         Reply

        • Just ensure you have restarted Nginx after installing Mcrypt.

          service nginx restart

           Reply

          • i install Centmin Mod (Linux, Nginx, MariaDB MySQL và PHP-FPM)

             

          • You would probably be better off asking for support in the Centmin community then I’m afraid. As the installation method here might not work for your setup.

             

  • Just for simplicity and to ensure that the latest epel repo is installed do the following:

    yum install epel-release

    this installs the repo from the Centos Extras repo

    then

    yum update
    yum install php-mcrypt

     Reply

    • Thanks Simon, is Centos Extras enabled by default?

       Reply

  • You are my hero. Thank you so much!

     Reply

  • Thanks You

     Reply

    • Thanks for this. It worked perfectly after searched for something to do this for a couple of day! Thanks to University or kent for the mirror service too.

       Reply

  • Well done – thank you so much for all your help on this.

     Reply

  • legend.

     Reply

  • Pingback: Finally installed! | Magento Walkthrough

  • I find solve this problem a long time. Until I found this website and I try your way.It’s work!. Thank you very very much 🙂

     Reply

  • Awesome! This is EXACTLY what I needed, first time I’ve got root access to a server and having a lot of fun!

     Reply

    • Remember, with great power comes great responsibility!

       Reply

  • Very good! Thanks!

     Reply

  • great!!!

     Reply

  • 404 for that rpm

     Reply

    • Just fixed it and updated to the latest version in the post for you!

       Reply

  • Thanks, works great!

     Reply

    • It works as described. Thanks much!

       Reply

  • The URL has changed again:

    rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm

    Two things:

    yum install php-mcrypt.x86_64

    if on 64bit

    and
    You need to restart Apache after installation.

     Reply

  • thanks man . It worked like a gem

     Reply

  • Pingback: Install mycrypt extension for PHP in CentOS 6.2 « ArIverson

  • Thanks for the excellent post! All OK, simple and fast!

     Reply

  • Thanks Mojo, I had a headache with Magento and found out that my new Centos 6 on my server hasn’t mcrypt installed on it. I did ‘yum update’ as well and with 240 updates I folded my hands to pray 🙂

    All seems to work.

    By the way, the URL changed, now it reads:

    http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm

    One question I still have. Since I have Plesk 10.4 on my machine as well, I wonder if that automatic updates will still work, or do I have to change ‘enabled’ to ‘0’ in epel.repo and epel-testing.repo?!

    Thanks again and kind regards from Munich!

     Reply

    • I’ve left EPEL enabled on my Plesk server and it hasn’t blown up yet!

       Reply

  • Hi, worked as planned, thanks, however when I now run the Plesk updater I get this, message. Would you be able to advise:

    WARNING: Third-party Yum repository ‘epel’ is enabled, installation may fail.

    Since you use one or more 3rd-party repos (say, atomic), be careful when installing different package versions from different repos as this may lead to installation failures. For example, you may encounter a problem if you first install PHP from a 3rd-party repo and then upgrade it using the Parallels repo. To avoid such situations, install and upgrade packages from the same repo.

    Thanks!
    David

     Reply

    • what you can do now that you have crypt installed is goto /etc/yum.repos.d you should have a .repo file referencing EPEL open that up in Nano (or Vi or Pico etc) and change enabled to 0 instead of 1.

      This will disable the repo, and should allow you to upgrade via Plesk (which is horrible)

      Did you do a yum update while you have EPEL activated? If not you should be fine to just disable it now you have mcrypt installed.

       Reply

      • Hi,

        Yes I ran yum update, is that bad?

        Thanks

         Reply

        • No not at all. If you have one removed epel as a repo a yum update probably won’t find much to update as the official centos repos are normally really behind.

           Reply

          • So really it’s safe just to disable the repo and update via plesk if need be and that’s it?
            Thanks again!
            David

             

          • Yeah. Plesk won’t be able to update some things as you will already have newer versions. Updates to plesk itself though should be fine. Haven’t broken my servers yet.

             

  • … won’t this also upgrade any packages that have newer versions in the EPEL? such as php, mysql etc? I would really like to find an mcrypt rpm that uses the upstream php version.

     Reply

    • It will however you can use the yum priorities plugin to determine what you do and don’t want to use from each repo.

      You can of course compile mcrypt and php from source but it’s a proper ball ache unless you really know why you’re doing.

       Reply

  • Many Thanks!

     Reply

  • thanks 🙂

     Reply

  • Valeu.. funcionou!!

     Reply

  • 非常感谢,终于解决了问题,:)

     Reply

  • ah thanks! what a relief

     Reply

    • same here!

       Reply

  • Thanks a lot….very nice help

     Reply

  • Thank You, 😉 for help me

     Reply

  • nice. Thank you!

     Reply

Leave a Reply

Mojowill Avatar

Who the Hell am I?

I'm Will, a full time web developer, geek and musician. I develop using PHP and MySQL and spend most of my time working with WordPress or CakePHP. When I'm not buried in code I'm gaming, cooking or writing and recording music in my studio. I like sci-fi, pancakes and coffee and am totally prepared for the zombie apocalypse...

Stalk me on these other sites...

Why not be super creepy and check me out on all these other sites, I think they call it social media?

%d bloggers like this: