How do I install a software package from the Extras Library on an EC2 instance running Amazon Linux 2?

6 minute read
-3

I have an Amazon Elastic Compute Cloud (Amazon EC2) instance that runs on Amazon Linux 2. I want to install a software package (known as a topic) from the amazon-linux-extras repository on my instance.

Short description

To install a software package from the Extras Library, first confirm that the amazon-linux-extras repository is installed on your instance. List the available software packages and turn on the one you want to install. Then, use yum to install the package.

Note: This resolution is only for Amazon Linux 2. These steps don't apply to Amazon Linux 1 2018.03 or Amazon Linux 2023.

Resolution

  1. Use SSH to connect to your EC2 Linux instance.

  2. Use rpm command to confirm that the amazon-linux-extras package is installed:

    $ rpm -qa |grep -i amazon-linux-extras

    If the amazon-linux-extras package isn't installed, then use yum to install it:

    $ sudo yum install -y amazon-linux-extras
  3. List the available topics. Note: The repository is regularly updated. The topics and versions that you see might differ from the following list:

    $ amazon-linux-extras
      2  httpd_modules            available    [ =1.0  =stable ]
      3  memcached1.5             available    \
            [ =1.5.1  =1.5.16  =1.5.17 ]
      9  R3.4                     available    [ =3.4.3  =stable ]
     10  rust1                    available    \
            [ =1.22.1  =1.26.0  =1.26.1  =1.27.2  =1.31.0  =1.38.0
              =stable ]
     18  libreoffice              available    \
            [ =5.0.6.2_15  =5.3.6.1  =stable ]
     19  gimp                     available    [ =2.8.22 ]
     20 †docker=latest            enabled      \
            [ =17.12.1  =18.03.1  =18.06.1  =18.09.9  =stable ]
     21  mate-desktop1.x          available    \
            [ =1.19.0  =1.20.0  =stable ]
     22  GraphicsMagick1.3        available    \
            [ =1.3.29  =1.3.32  =1.3.34  =stable ]
     23 †tomcat8.5                available    \
            [ =8.5.31  =8.5.32  =8.5.38  =8.5.40  =8.5.42  =8.5.50
              =stable ]
     24  epel                     available    [ =7.11  =stable ]
     25  testing                  available    [ =1.0  =stable ]
     26  ecs                      available    [ =stable ]
     27 †corretto8                available    \
            [ =1.8.0_192  =1.8.0_202  =1.8.0_212  =1.8.0_222  =1.8.0_232
              =1.8.0_242  =stable ]
     32  lustre2.10               available    \
            [ =2.10.5  =2.10.8  =stable ]
     33 †java-openjdk11           available    [ =11  =stable ]
     34  lynis                    available    [ =stable ]
     36  BCC                      available    [ =0.x  =stable ]
     37  mono                     available    [ =5.x  =stable ]
     38  nginx1                   available    [ =stable ]
     40  mock                     available    [ =stable ]
     43  livepatch                available    [ =stable ]
     44 †python3.8                available    [ =stable ]
     45  haproxy2                 available    [ =stable ]
     46  collectd                 available    [ =stable ]
     47  aws-nitro-enclaves-cli   available    [ =stable ]
     48  R4                       available    [ =stable ]
      _  kernel-5.4               available    [ =stable ]
     50  selinux-ng               available    [ =stable ]
     52  tomcat9                  available    [ =stable ]
     53  unbound1.13              available    [ =stable ]
     54 †mariadb10.5              available    [ =stable ]
     55  kernel-5.10=latest       enabled      [ =stable ]
     56  redis6                   available    [ =stable ]
     57 †ruby3.0                  available    [ =stable ]
     58 †postgresql12             available    [ =stable ]
     59 †postgresql13             available    [ =stable ]
     60  mock2                    available    [ =stable ]
     61  dnsmasq2.85=latest       enabled      [ =stable ]
     62  kernel-5.15              available    [ =stable ]
     63 †postgresql14             available    [ =stable ]
     64  firefox                  available    [ =stable ]
     65  lustre                   available    [ =stable ]
     66 †php8.1=latest            enabled      [ =stable ]
     67  awscli1                  available    [ =stable ]
      _ †php8.2                   available    [ =stable ]
      _  dnsmasq                  available    [ =stable ]
     70  unbound1.17              available    [ =stable ]
     72  collectd-python3         available    [ =stable ]
    † Note on end-of-support. Use 'info' subcommand.
  4. Activate the desired topic. The output shows the commands required for installation. For example, use the following command to activate the PHP 8.1 topic:

    $ sudo amazon-linux-extras enable php8.1
    Topic php8.1 has end-of-support date of 2024-11-25
      2  httpd_modules            available    [ =1.0  =stable ]
      3  memcached1.5             available    \
            [ =1.5.1  =1.5.16  =1.5.17 ]
      9  R3.4                     available    [ =3.4.3  =stable ]
     10  rust1                    available    \
            [ =1.22.1  =1.26.0  =1.26.1  =1.27.2  =1.31.0  =1.38.0
              =stable ]
     18  libreoffice              available    \
            [ =5.0.6.2_15  =5.3.6.1  =stable ]
     19  gimp                     available    [ =2.8.22 ]
     20 †docker=latest            enabled      \
            [ =17.12.1  =18.03.1  =18.06.1  =18.09.9  =stable ]
     21  mate-desktop1.x          available    \
            [ =1.19.0  =1.20.0  =stable ]
     22  GraphicsMagick1.3        available    \
            [ =1.3.29  =1.3.32  =1.3.34  =stable ]
     23 †tomcat8.5                available    \
            [ =8.5.31  =8.5.32  =8.5.38  =8.5.40  =8.5.42  =8.5.50
              =stable ]
     24  epel                     available    [ =7.11  =stable ]
     25  testing                  available    [ =1.0  =stable ]
     26  ecs                      available    [ =stable ]
     27 †corretto8                available    \
            [ =1.8.0_192  =1.8.0_202  =1.8.0_212  =1.8.0_222  =1.8.0_232
              =1.8.0_242  =stable ]
     32  lustre2.10               available    \
            [ =2.10.5  =2.10.8  =stable ]
     33 †java-openjdk11           available    [ =11  =stable ]
     34  lynis                    available    [ =stable ]
     36  BCC                      available    [ =0.x  =stable ]
     37  mono                     available    [ =5.x  =stable ]
     38  nginx1                   available    [ =stable ]
     40  mock                     available    [ =stable ]
     43  livepatch                available    [ =stable ]
     44 †python3.8                available    [ =stable ]
     45  haproxy2                 available    [ =stable ]
     46  collectd                 available    [ =stable ]
     47  aws-nitro-enclaves-cli   available    [ =stable ]
     48  R4                       available    [ =stable ]
      _  kernel-5.4               available    [ =stable ]
     50  selinux-ng               available    [ =stable ]
     52  tomcat9                  available    [ =stable ]
     53  unbound1.13              available    [ =stable ]
     54 †mariadb10.5              available    [ =stable ]
     55  kernel-5.10=latest       enabled      [ =stable ]
     56  redis6                   available    [ =stable ]
     57 †ruby3.0                  available    [ =stable ]
     58 †postgresql12             available    [ =stable ]
     59 †postgresql13             available    [ =stable ]
     60  mock2                    available    [ =stable ]
     61  dnsmasq2.85=latest       enabled      [ =stable ]
     62  kernel-5.15              available    [ =stable ]
     63 †postgresql14             available    [ =stable ]
     64  firefox                  available    [ =stable ]
     65  lustre                   available    [ =stable ]
     66 †php8.1=latest            enabled      [ =stable ]
     67  awscli1                  available    [ =stable ]
      _ †php8.2                   available    [ =stable ]
      _  dnsmasq                  available    [ =stable ]
     70  unbound1.17              available    [ =stable ]
     72  collectd-python3         available    [ =stable ]
    † Note on end-of-support. Use 'info' subcommand.
  5. Use yum to Install the packages. For example, to install the PHP 8.1 topic, use the following command:

    $ sudo yum clean metadata && sudo yum install php-cli php-pdo php-fpm php-json php-mysqlnd
  6. To verify the installation and confirm the software version, run the following command:

    $ sudo yum list installed php-cli php-pdo php-fpm php-json php-mysqlnd
    Loaded plugins: langpacks, priorities, update-motd
    Installed Packages
    php-cli.x86_64                                                8.1.23-1.amzn2                                            @amzn2extra-php8.1
    php-fpm.x86_64                                                8.1.23-1.amzn2                                            @amzn2extra-php8.1
    php-mysqlnd.x86_64                                            8.1.23-1.amzn2                                            @amzn2extra-php8.1
    php-pdo.x86_64                                                8.1.23-1.amzn2                                            @amzn2extra-php8.1
    
    $ php --version
    PHP 8.1.23 (cli) (built: Sep 15 2023 21:56:29) (NTS)
    Copyright (c) The PHP Group
    Zend Engine v4.1.23, Copyright (c) Zend Technologies

Related information

Amazon Linux 2

Find and install software packages on an Amazon Linux instance

Package management tool

AWS OFFICIAL
AWS OFFICIALUpdated 3 months ago
11 Comments

I could install other packages except 'amazon-linux-extras'

Issue:

$ which amazon-linux-extras

(response) /usr/bin/which: no amazon-linux-extras in (/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/lib/snapd/snap/bin)

Asking for Solution:

How can the above error be resolved? ...cause ($ sudo yum install amazon-linux-extras) Error: Unable to find a match: amazon-linux-extras

replied a year ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

profile pictureAWS
MODERATOR
replied a year ago

Not worked amazon-linux-extras not found

replied a year ago

This article doesn't work for Amazon Linux 2023. Just trying to install Java 11 from amazon-linux-extras, with out luck.

see results

[ec2-user@ip-172-31-99-999 ~]$ sudo yum install -y amazon-linux-extras
Last metadata expiration check: 0:09:51 ago on Tue Apr  4 14:04:54 2023.
No match for argument: amazon-linux-extras
Error: Unable to find a match: amazon-linux-extras

and

repo list doesn't contain amazon-linux-extras. So can't be enabled.

[ec2-user@ip-172-31-47-190 ~]$ sudo yum repolist all
repo id                                             repo name                                                                                   status
amazonlinux                                         Amazon Linux 2023 repository                                                                enabled
amazonlinux-debuginfo                               Amazon Linux 2023 repository - Debug                                                        disabled
amazonlinux-source                                  Amazon Linux 2023 repository - Source packages                                              disabled
kernel-livepatch                                    Amazon Linux 2023 Kernel Livepatch repository                                               enabled
kernel-livepatch-source                             Amazon Linux 2023 Kernel Livepatch repository - Source packages                             disabled
[ec2-user@ip-172-31-47-190 ~]$ 
amble42
replied a year ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

profile pictureAWS
MODERATOR
replied a year ago

This also does not work for AL2 v5 image (aws/codebuild/amazonlinux2-x86_64-standard:5.0)

AWS
Alex
replied 7 months ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

profile pictureAWS
MODERATOR
replied 7 months ago

For brand new Amazon Linux 2 instance

which amazon-linux-extras/usr/bin/amazon-linux-extras

results in:

/usr/bin/which: no amazon-linux-extras in (./amazon-linux-extras/usr/bin) yum install -y amazon-linux-extras

results in:

Loaded plugins: extras_suggestions, langpacks, priorities, update-motd, versionlock 249 packages excluded due to repository priority protections Package amazon-linux-extras-2.0.3-1.amzn2.noarch already installed and latest version Nothing to do

Extras is already installed, but the which command looking in the wrong place.

which amazon-linux-extras

results in:

/bin/amazon-linux-extras

profile picture
badfun
replied 6 months ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

profile pictureAWS
MODERATOR
replied 6 months ago

amazon-linux-extras is no longer available for Amazon Linux 2023. What is the alternative?

replied a month ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

profile pictureAWS
MODERATOR
replied a month ago