apt is the easiest way to install application packages for Ubuntu. These packages are stored in repositories hosted and managed by Ubuntu. It contains a lot of packages or applications needed for almost every Ubuntu user, though sometimes packages that you need are not at all available in the default repository or not the version that you need.

To get around this, some users or corporations host packages in third-party repositories which is called PPA or Personal Package Archives. You can add the repositories to your Ubuntu system using add-apt-repository tool and then install the packages using apt.

Steps to add third-party apt repository on Ubuntu:

  1. Search for PPA repository to install from Ubuntu's Personal Package Archives site.
    https://launchpad.net/ubuntu/+ppas
  2. Launch terminal.
  3. Add PPA apt repository using add-apt-repository.
    $ sudo add-apt-repository ppa:ondrej/php
    [sudo] password for user:
     Co-installable PHP versions: PHP 5.6, PHP 7.x and most requested extensions are included. Only Supported Versions of PHP (http://php.net/supported-versions.php) for Supported Ubuntu Releases (https://wiki.ubuntu.com/Releases) are provided. Don't ask for end-of-life PHP versions or Ubuntu release, they won't be provided.
    
    Debian oldstable and stable packages are provided as well: https://deb.sury.org/#debian-dpa
    
    You can get more information about the packages at https://deb.sury.org
    
    BUGS&FEATURES: This PPA now has a issue tracker:
    https://deb.sury.org/#bug-reporting
    
    CAVEATS:
    1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman
    2. If you are using apache2, you are advised to add ppa:ondrej/apache2
    3. If you are using nginx, you are advised to add ppa:ondrej/nginx-mainline
       or ppa:ondrej/nginx
    
    PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly: https://donate.sury.org/
    
    WARNING: add-apt-repository is broken with non-UTF-8 locales, see
    https://github.com/oerdnj/deb.sury.org/issues/56 for workaround:
    
    # LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
     More info: https://launchpad.net/~ondrej/+archive/ubuntu/php
    Press [ENTER] to continue or Ctrl-c to cancel adding it.
    ##### snipped
  4. Update package list for apt.
    $ sudo apt update
    Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB]      
    Hit:2 http://ppa.launchpad.net/ondrej/php/ubuntu focal InRelease               
    Hit:3 http://jp.archive.ubuntu.com/ubuntu focal InRelease
    Get:4 http://jp.archive.ubuntu.com/ubuntu focal-updates InRelease [111 kB]
    Get:5 http://jp.archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB]
    Fetched 317 kB in 3s (97.8 kB/s)    
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    8 packages can be upgraded. Run 'apt list --upgradable' to see them.
  5. Upgrade installed packages based on new package listing.
    $ sudo apt dist-upgrade --assume-yes
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    Calculating upgrade... Done
    The following packages will be upgraded:
      libgd3 libidn2-0 libpcre2-32-0 libpcre2-8-0 libpcre3 libssl1.1 libxml2
      openssl
    8 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    Need to get 3,894 kB of archives.
    After this operation, 100 kB of additional disk space will be used.
    Get:1 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 libpcre3 amd64 2:8.44-1+ubuntu20.04.1+deb.sury.org+1 [240 kB]
    Get:2 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 libidn2-0 amd64 2.3.0-1+ubuntu20.04.1+deb.sury.org+2 [68.7 kB]
    Get:3 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 libpcre2-8-0 amd64 10.35-4+ubuntu20.04.1+deb.sury.org+1 [201 kB]
    Get:4 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 libgd3 amd64 2.3.0-2+ubuntu20.04.1+deb.sury.org+1 [135 kB]
    ##### snipped
  6. Install new packages made available from the newly added repository.
    $ sudo apt install --assume-yes php5.6
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following additional packages will be installed:
      apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php5.6 libapr1
      libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php-common
      php5.6-cli php5.6-common php5.6-json php5.6-opcache php5.6-readline
    Suggested packages:
      apache2-doc apache2-suexec-pristine | apache2-suexec-custom php-pear
    The following NEW packages will be installed:
      apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php5.6 libapr1
      libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php-common
      php5.6 php5.6-cli php5.6-common php5.6-json php5.6-opcache php5.6-readline
    0 upgraded, 17 newly installed, 0 to remove and 0 not upgraded.
    Need to get 7,503 kB of archives.
    After this operation, 24.2 MB of additional disk space will be used.
Share this guide!
Discuss the article:

Comment anonymously. Login not required.

Share!