2

Seems like new versions of the Amazon AMI on EC2 don't have the php-mcrypt package available. How do I get it?

$ sudo yum install php-mcrypt
Loaded plugins: langpacks, priorities, update-motd
amzn2-core
No package php-mcrypt available.
Error: Nothing to do

In general, how do I figure out how to solve "missing packages" problems like this?

3
  • Explicitly setting the version is not a solution. php54- packages are also all missing.
    – Meekohi
    Feb 1 '18 at 19:10
  • sudo yum info php and php -v indicate version is php 5.4.16
    – Meekohi
    Feb 1 '18 at 19:11
  • They don't ship it. Use something other than Amazon Linux. Feb 1 '18 at 19:14
2

I was able to install php-mcrypt following the suggestion on this page using EPEL for EL 7 into AWS release 2.0 (2017.12) Linux.

This is an Amazon instance running Amazon Linux 2 (2017.12) which I tested with...

# cat /etc/system-release
Amazon Linux release 2.0 (2017.12) LTS Release Candidate
# curl http://169.254.169.254/latest/meta-data/ami-id
ami-428aa838

The people at amazon claim that AWS distro is not based specifically on any version of RedHat, so there is no guarantee of compatibility, but comparing the versions of the PHP packages in EPEL for Enterprise linux 7, and the amazon ones, suggests they are building from the same source;

for example the build numbers are exactly the same Version : 5.4.16 on the packages from amzn2-core and epel

Name        : php-mcrypt
Version     : 5.4.16
Release     : 7.el7
From repo   : epel

vs

Name        : php
Version     : 5.4.16
Release     : 43.amzn2.0.1
From repo   : amzn2-core

So I am not surprised the package from epel installed on the 2017.12 AWS AMI no problem...

# yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
...
  Installing : epel-release-7-11.noarch        1/1
  Verifying  : epel-release-7-11.noarch        1/1

Installed:
  epel-release.noarch 0:7-11

Complete!

and then installed php-mcrypt;

# yum install -y --enablerepo=epel php-mcrypt
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libmcrypt-2.5.8-13.el7.x86_64      1/2 
  Installing : php-mcrypt-5.4.16-7.el7.x86_64     2/2 
  Verifying  : libmcrypt-2.5.8-13.el7.x86_64      1/2 
  Verifying  : php-mcrypt-5.4.16-7.el7.x86_64     2/2 

Installed:
  php-mcrypt.x86_64 0:5.4.16-7.el7                                                                                                    

Dependency Installed:
  libmcrypt.x86_64 0:2.5.8-13.el7                                                                                                     

Complete!

and then you can test to see that mcrypt extensions is installed like so;

# php -i "(command-line 'phpinfo()')" | grep mcrypt
/etc/php.d/mcrypt.ini,
Registered Stream Filters => zlib.*, bzip2.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, mcrypt.*, mdecrypt.*
mcrypt
mcrypt support => enabled
mcrypt_filter support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value

I also disabled epel, as I don't want to end up with a mix of packages from both repos beyond the minimum;

yum-config-manager --disablerepo=epel



# yum repolist all
Loaded plugins: langpacks, priorities, update-motd
repo id                      repo name                                                                  status
amzn2-core/2017.12/x86_64    Amazon Linux 2 core       enabled: 7,157
epel/x86_64                  Extra Packages            disabled
2
  • 1
    Be careful. Amazon Linux 2 might be forked from CentOS 7, but that doesn't mean compatibility is guaranteed. This has historically been a serious problem with Amazon Linux. If you want to be sure of compatibility, just save yourself a lot of trouble and go with CentOS 7. Feb 1 '18 at 23:15
  • Ah, indeed. I only span the instance up to do the test! Currently most of my work is migrating from EL6 to EL7 using ansible...
    – Tom
    Feb 1 '18 at 23:29
0

I have been searching it a lot and got it working.

Try This.

# amazon-linux-extras install epel
# yum install php-mcrypt
1
  • 1
    The same compatibility warning applies here. You should expect this to break in the future. Mar 28 '19 at 17:08
0

Found an even easier solution. Just run:

yum install php-pecl-mcrypt

This works for PHP 7.3 and on Amazon Linux 2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.