Skip to content

How do I install a package that's not available in the repository on my Amazon EC2 Linux instance?

3 minute read
0

I want to install a package on my Amazon Elastic Compute Cloud (Amazon EC2) Linux instance. However, the package isn't available in the standard package management repository.

Resolution

To install packages that aren't available in the standard repository onto your EC2 Linux instance, take one of the following actions.

Note: The following resolution uses the PostgreSQL repository as an example.

Add official package repositories to your instance

If the package is from an official repository, then complete the following steps to add the repository to your instance:

  1. To install the PostgreSQL repository, run the following command based on your Linux distribution.
    Amazon Linux 2 (AL2), Red Hat Enterprise Linux (RHEL) 7, and CentOS 7:

    sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

    Amazon Linux 2023 (AL2023), RHEL 8+, and CentOS 8+:

    sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
  2. (Optional) If you use AL2023, RHEL 8+, or CentOS 8+, then run the following command to install the PostgreSQL client:

    sudo dnf install postgresql17
  3. Run the following command to check the repository version:

    pg_dump –version
  4. If you have multiple versions installed, then run the following command to check the latest version:

    /usr/pgsql-17/bin/pg_dump --version

Manually install the packages from the source

If packages aren't officially available for your operating system (OS) version, then complete the following steps to manually install them from source code:

  1. Run the following command to install development tools and dependencies:

    sudo yum groupinstall "Development Tools" -y
  2. Run the following command to install required libraries:

    sudo dnf install readline-devel zlib-devel bison flex openssl-devel -y 
    sudo dnf install -y icu libicu libicu-devel
  3. Run the following command to download the source code:

    wget https://ftp.postgresql.org/pub/source/v16.0/postgresql-16.0.tar.gz
  4. Run the following command to extract the archive:

    tar -xvzf postgresql-16.0.tar.gz 
    cd postgresql-16.0
  5. Run the following command to configure, compile, and install the repository:

    ./configure make sudo make install
  6. Run the following command to make sure that the binary exists at the correct file path:

    /usr/local/pgsql/bin/psql --version

    Note: It's a best practice to upgrade to later OS versions. Updates for later OS versions don't require manual compilation.

Related information

Why can't I install a package onto my Amazon EC2 Linux instance?

How do I troubleshoot a missing or broken package manager in my Amazon EC2 Linux instance?

AWS OFFICIALUpdated 23 days ago