Skip to content

How do I install a software package from the Extras Library on an EC2 instance that runs AL2?

6 minute read
-3

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

Resolution

Note: The following resolution applies only to instances that run on AL2. You can't use the following resolution steps for instances that run on Amazon Linux 2023 (AL2023).

To install a software package, complete the following steps:

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

  2. To check whether you installed the amazon-linux-extras package, run the following command:

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

    If you didn't install the amazon-linux-extras package, then run the following command to install the package:

    sudo yum install -y amazon-linux-extras
  3. To list all available topics and versions, run the following command:

    amazon-linux-extras  

    Example output:

    $ 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.

    Note: AWS regularly updates the Extras Library repository.

  4. To activate the topic that you want to use, run the following command:

    sudo amazon-linux-extras enable php8.1

    Note: Replace php8.1 with the topic name.
    Example output:

    $ sudo amazon-linux-extras enable php8
    .1Topic 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. To install the packages on the topic, run the following command:

    sudo yum clean metadata && sudo yum install php-cli php-pdo php-fpm php-json php-mysqlnd

    Note: Replace php-cli php-pdo php-fpm php-json php-mysqlnd with the list of software packages in your topic.

  6. To verify the installation, run the following command:

    sudo yum list installed php-cli php-pdo php-fpm php-json php-mysqlndLoaded plugins: langpacks, priorities, update-motd

    Note: Replace php-cli php-pdo php-fpm php-json php-mysqlnd with the list of software packages in your topic.
    Example output:

    $ sudo yum list installed php-cli php-pdo php-fpm php-json php-mysqlndLoaded 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
  7. To confirm the software version, run the following command:

    php --version

    Example output:

    $ 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

Amazon Linux 2023 FAQs

Find and install software packages on an AL2 instance

Package management tool

AWS OFFICIALUpdated 9 months ago
12 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 3 years ago

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

AWS
MODERATOR
replied 3 years 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 ~]$ 
replied 3 years ago

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

AWS
MODERATOR
replied 3 years ago

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

AWS
replied 2 years ago

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

AWS
EXPERT
replied 2 years 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

replied 2 years ago

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

AWS
MODERATOR
replied 2 years ago

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

replied 2 years ago

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

AWS
MODERATOR
replied 2 years ago

BEWARE:

Despite its name, the aws/codebuild/amazonlinux2-x86_64-standard:5.0 image is actually an Amazon Linux 2023 image.

This is not apparent at all when selecting the image from the codebuild console, but it is mentioned in the docs

Also see this issue: https://github.com/aws/aws-codebuild-docker-images/issues/726

replied 2 years ago

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

AWS
MODERATOR
replied 2 years ago