APT and apt-get are essential package management tools for Ubuntu and other Debian-based Linux distributions. These tools enable users to easily install and update software packages hosted in the default repositories containing a wide range of commonly used and supported packages.

However, sometimes, users need software that is unavailable in the default repositories. Adding third-party repositories or Personal Package Archives (PPAs) is necessary in these cases. PPAs allow users to access and install software not included in the default repositories, often due to niche use cases or more frequent update requirements.

The add-apt-repository command can be used to add a PPA repository in Ubuntu. This command simplifies adding third-party repositories to your apt sources list, enabling the installation and update of software packages from these sources as easily as the default repositories. PPAs can be found on Launchpad or vendor websites and, once added, can be managed using apt or apt-get.

Steps to add PPA repository for apt on Ubuntu:

  1. Search for the desired PPA repository on the Ubuntu Personal Package Archives site.
    https://launchpad.net/ubuntu/+ppas
  2. Open the terminal.
  3. Add the PPA repository using add-apt-repository.
    $ sudo add-apt-repository ppa:ondrej/php
    [sudo] password for user: 
    PPA publishes dbgsym, you may need to include 'main/debug' component
    Repository: 'Types: deb
    URIs: https://ppa.launchpadcontent.net/ondrej/php/ubuntu/
    Suites: noble
    Components: main
    '
    Description:
    Co-installable PHP versions: PHP 5.6, PHP 7.x, PHP 8.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
    
    IMPORTANT: The <foo>-backports is now required on older Ubuntu releases.
    
    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
    Adding repository.
    Press [ENTER] to continue or Ctrl-c to cancel.
  4. Press [ENTER] to confirm and continue.
    Hit:1 http://ports.ubuntu.com/ubuntu-ports noble InRelease
    Get:2 http://ports.ubuntu.com/ubuntu-ports noble-updates InRelease [89.7 kB]
    Get:3 https://ppa.launchpadcontent.net/ondrej/php/ubuntu noble InRelease [23.6 kB]
    Get:4 https://ppa.launchpadcontent.net/ondrej/php/ubuntu noble/main arm64 Packages [90.8 kB]
    Get:5 http://ports.ubuntu.com/ubuntu-ports noble-backports InRelease [89.7 kB]
    Hit:6 http://ports.ubuntu.com/ubuntu-ports noble-security InRelease
    Get:7 https://ppa.launchpadcontent.net/ondrej/php/ubuntu noble/main Translation-en [29.8 kB]
    Get:8 http://ports.ubuntu.com/ubuntu-ports noble-updates/main arm64 Packages [27.5 kB]
    Get:9 http://ports.ubuntu.com/ubuntu-ports noble-updates/universe arm64 Packages [17.3 kB]
    Fetched 368 kB in 4s (92.2 kB/s)
    Reading package lists... Done
    W: https://ppa.launchpadcontent.net/ondrej/php/ubuntu/dists/noble/InRelease: Signature by key 14AA40EC0831756756D7F66C4F4EA0AAE5267A6C uses weak algorithm (rsa1024)
  5. Update the package list for apt.
    $ sudo apt update
    Hit:1 http://ports.ubuntu.com/ubuntu-ports noble InRelease
    Hit:2 http://ports.ubuntu.com/ubuntu-ports noble-updates InRelease
    Hit:3 http://ports.ubuntu.com/ubuntu-ports noble-backports InRelease
    Hit:4 http://ports.ubuntu.com/ubuntu-ports noble-security InRelease
    Hit:5 https://ppa.launchpadcontent.net/ondrej/php/ubuntu noble InRelease
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    13 packages can be upgraded. Run 'apt list --upgradable' to see them.
    W: https://ppa.launchpadcontent.net/ondrej/php/ubuntu/dists/noble/InRelease: Signature by key 14AA40EC0831756756D7F66C4F4EA0AAE5267A6C uses weak algorithm (rsa1024)
  6. Upgrade installed packages based on the new package listing.
    $ sudo apt dist-upgrade --assume-yes
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    Calculating upgrade... Done
    Receive additional future security updates with Ubuntu Pro.
    Learn more about Ubuntu Pro at https://ubuntu.com/pro
    The following packages will be upgraded:
      libgd3 libpcre2-32-0 libpcre2-8-0 libxml2
    4 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    Need to get 1,342 kB of archives.
    After this operation, 0 B of additional disk space will be used.
    Get:1 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy/main arm64 libpcre2-8-0 arm64 10.40-1+ubuntu22.04.1+deb.sury.org+1 [212 kB]
    Get:2 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy/main arm64 libgd3 arm64 2.3.3-5+ubuntu22.04.1+deb.sury.org+1 [140 kB]
    Get:3 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy/main arm64 libpcre2-32-0 arm64 10.40-1+ubuntu22.04.1+deb.sury.org+1 [186 kB]
    Get:4 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy/main arm64 libxml2 arm64 2.9.14+dfsg-0+ubuntu22.04.1+deb.sury.org+1 [804 kB]
    Fetched 1,342 kB in 5s (245 kB/s)                           
    (Reading database ... 206576 files and directories currently installed.)
    Preparing to unpack .../libpcre2-8-0_10.40-1+ubuntu22.04.1+deb.sury.org+
    1_arm64.deb ...
    Unpacking libpcre2-8-0:arm64 (10.40-1+ubuntu22.04.1+deb.sury.org+1) over
     (10.39-3ubuntu0.1) ...
    Setting up libpcre2-8-0:arm64 (10.40-1+ubuntu22.04.1+deb.sury.org+1) ...
    (Reading database ... 206576 files and directories currently installed.)
    Preparing to unpack .../libgd3_2.3.3-5+ubuntu22.04.1+deb.sury.org+1_arm6
    4.deb ...
    Unpacking libgd3:arm64 (2.3.3-5+ubuntu22.04.1+deb.sury.org+1) over (2.3.
    0-2ubuntu2) ...
    Preparing to unpack .../libpcre2-32-0_10.40-1+ubuntu22.04.1+deb.sury.org
    +1_arm64.deb ...
    Unpacking libpcre2-32-0:arm64 (10.40-1+ubuntu22.04.1+deb.sury.org+1) ove
    r (10.39-3ubuntu0.1) ...
    Preparing to unpack .../libxml2_2.9.14+dfsg-0+ubuntu22.04.1+deb.sury.org
    +1_arm64.deb ...
    Unpacking libxml2:arm64 (2.9.14+dfsg-0+ubuntu22.04.1+deb.sury.org+1) ove
    r (2.9.13+dfsg-1ubuntu0.1) ...
    Setting up libpcre2-32-0:arm64 (10.40-1+ubuntu22.04.1+deb.sury.org+1) ..
    .
    Setting up libgd3:arm64 (2.3.3-5+ubuntu22.04.1+deb.sury.org+1) ...
    Setting up libxml2:arm64 (2.9.14+dfsg-0+ubuntu22.04.1+deb.sury.org+1) ..
    .
    Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
    ##### snipped
  7. Install new packages available from the newly added repository.
    $ sudo apt install --assume-yes php8.2
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    The following additional packages will be installed:
      apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php8.2 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap php-common
      php8.2-cli php8.2-common php8.2-opcache php8.2-readline
    Suggested packages:
      apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser php-pear
    The following NEW packages will be installed:
      apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php8.2 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap php-common
      php8.2 php8.2-cli php8.2-common php8.2-opcache php8.2-readline
    0 upgraded, 15 newly installed, 0 to remove and 0 not upgraded.
    Need to get 6,769 kB of archives.
    After this operation, 28.7 MB of additional disk space will be used.
    Get:1 http://us.ports.ubuntu.com/ubuntu-ports jammy/main arm64 libapr1 arm64 1.7.0-8build1 [105 kB]
    Get:2 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy/main arm64 php-common all 2:92+ubuntu22.04.1+deb.sury.org+1 [16.6 kB]
    Get:3 http://us.ports.ubuntu.com/ubuntu-ports jammy/main arm64 libaprutil1 arm64 1.6.1-5ubuntu4 [93.0 kB]
    Get:4 http://us.ports.ubuntu.com/ubuntu-ports jammy/main arm64 libaprutil1-dbd-sqlite3 arm64 1.6.1-5ubuntu4 [11.2 kB]
    Get:5 http://us.ports.ubuntu.com/ubuntu-ports jammy/main arm64 libaprutil1-ldap arm64 1.6.1-5ubuntu4 [9,048 B]
    Get:6 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy/main arm64 php8.2-common arm64 8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1 [704 kB]
    Get:7 http://us.ports.ubuntu.com/ubuntu-ports jammy-updates/main arm64 apache2-bin arm64 2.4.52-1ubuntu4.1 [1,300 kB]
    Get:8 http://us.ports.ubuntu.com/ubuntu-ports jammy-updates/main arm64 apache2-data all 2.4.52-1ubuntu4.1 [165 kB]
    Get:9 http://us.ports.ubuntu.com/ubuntu-ports jammy-updates/main arm64 apache2-utils arm64 2.4.52-1ubuntu4.1 [87.8 kB]
    Get:10 http://us.ports.ubuntu.com/ubuntu-ports jammy-updates/main arm64 apache2 arm64 2.4.52-1ubuntu4.1 [97.8 kB]
    Get:11 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy/main arm64 php8.2-opcache arm64 8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1 [582 kB]
    Get:12 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy/main arm64 php8.2-readline arm64 8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1 [12.9 kB]
    Get:13 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy/main arm64 php8.2-cli arm64 8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1 [1,815 kB]
    Get:14 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy/main arm64 libapache2-mod-php8.2 arm64 8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1 [1,747 kB]
    Get:15 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy/main arm64 php8.2 all 8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1 [23.0 kB]        
    Fetched 6,769 kB in 11s (620 kB/s)                                                                                                              
    Selecting previously unselected package libapr1:arm64.
    (Reading database ... 206577 files and directories currently installed.)
    Preparing to unpack .../00-libapr1_1.7.0-8build1_arm64.deb ...
    Unpacking libapr1:arm64 (1.7.0-8build1) ...
    Selecting previously unselected package libaprutil1:arm64.
    Preparing to unpack .../01-libaprutil1_1.6.1-5ubuntu4_arm64.deb ...
    Unpacking libaprutil1:arm64 (1.6.1-5ubuntu4) ...
    Selecting previously unselected package libaprutil1-dbd-sqlite3:arm64.
    Preparing to unpack .../02-libaprutil1-dbd-sqlite3_1.6.1-5ubuntu4_arm64.deb ...
    Unpacking libaprutil1-dbd-sqlite3:arm64 (1.6.1-5ubuntu4) ...
    Selecting previously unselected package libaprutil1-ldap:arm64.
    Preparing to unpack .../03-libaprutil1-ldap_1.6.1-5ubuntu4_arm64.deb ...
    Unpacking libaprutil1-ldap:arm64 (1.6.1-5ubuntu4) ...
    Selecting previously unselected package apache2-bin.
    Preparing to unpack .../04-apache2-bin_2.4.52-1ubuntu4.1_arm64.deb ...
    Unpacking apache2-bin (2.4.52-1ubuntu4.1) ...
    Selecting previously unselected package apache2-data.
    Preparing to unpack .../05-apache2-data_2.4.52-1ubuntu4.1_all.deb ...
    Unpacking apache2-data (2.4.52-1ubuntu4.1) ...
    Selecting previously unselected package apache2-utils.
    Preparing to unpack .../06-apache2-utils_2.4.52-1ubuntu4.1_arm64.deb ...
    Unpacking apache2-utils (2.4.52-1ubuntu4.1) ...
    Selecting previously unselected package apache2.
    Preparing to unpack .../07-apache2_2.4.52-1ubuntu4.1_arm64.deb ...
    Unpacking apache2 (2.4.52-1ubuntu4.1) ...
    Selecting previously unselected package php-common.
    Preparing to unpack .../08-php-common_2%3a92+ubuntu22.04.1+deb.sury.org+1_all.deb ...
    Unpacking php-common (2:92+ubuntu22.04.1+deb.sury.org+1) ...
    Selecting previously unselected package php8.2-common.
    Preparing to unpack .../09-php8.2-common_8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1_arm64.deb ...
    Unpacking php8.2-common (8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1) ...
    Selecting previously unselected package php8.2-opcache.
    Preparing to unpack .../10-php8.2-opcache_8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1_arm64.deb ...
    Unpacking php8.2-opcache (8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1) ...
    Selecting previously unselected package php8.2-readline.
    Preparing to unpack .../11-php8.2-readline_8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1_arm64.deb ...
    Unpacking php8.2-readline (8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1) ...
    Selecting previously unselected package php8.2-cli.
    Preparing to unpack .../12-php8.2-cli_8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1_arm64.deb ...
    Unpacking php8.2-cli (8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1) ...
    Selecting previously unselected package libapache2-mod-php8.2.
    Preparing to unpack .../13-libapache2-mod-php8.2_8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1_arm64.deb ...
    Unpacking libapache2-mod-php8.2 (8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1) ...
    Selecting previously unselected package php8.2.
    Preparing to unpack .../14-php8.2_8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1_all.deb ...
    Unpacking php8.2 (8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1) ...
    Setting up php-common (2:92+ubuntu22.04.1+deb.sury.org+1) ...
    Created symlink /etc/systemd/system/timers.target.wants/phpsessionclean.timer → /lib/systemd/system/phpsessionclean.timer.
    Setting up php8.2-common (8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1) ...
    
    Creating config file /etc/php/8.2/mods-available/calendar.ini with new version
    
    Creating config file /etc/php/8.2/mods-available/ctype.ini with new version
    
    Creating config file /etc/php/8.2/mods-available/exif.ini with new version
    
    Creating config file /etc/php/8.2/mods-available/fileinfo.ini with new version
    
    Creating config file /etc/php/8.2/mods-available/ffi.ini with new version
    
    Creating config file /etc/php/8.2/mods-available/ftp.ini with new version
    
    Creating config file /etc/php/8.2/mods-available/gettext.ini with new version
    
    Creating config file /etc/php/8.2/mods-available/iconv.ini with new version
    
    Creating config file /etc/php/8.2/mods-available/pdo.ini with new version
    
    Creating config file /etc/php/8.2/mods-available/phar.ini with new version
    
    Creating config file /etc/php/8.2/mods-available/posix.ini with new version
    
    Creating config file /etc/php/8.2/mods-available/shmop.ini with new version
    
    Creating config file /etc/php/8.2/mods-available/sockets.ini with new version
    
    Creating config file /etc/php/8.2/mods-available/sysvmsg.ini with new version
    
    Creating config file /etc/php/8.2/mods-available/sysvsem.ini with new version
    
    Creating config file /etc/php/8.2/mods-available/sysvshm.ini with new version
    
    Creating config file /etc/php/8.2/mods-available/tokenizer.ini with new version
    Setting up php8.2-opcache (8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1) ...
    
    Creating config file /etc/php/8.2/mods-available/opcache.ini with new version
    Setting up php8.2-readline (8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1) ...
    
    Creating config file /etc/php/8.2/mods-available/readline.ini with new version
    Setting up libapr1:arm64 (1.7.0-8build1) ...
    Setting up apache2-data (2.4.52-1ubuntu4.1) ...
    Setting up php8.2-cli (8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1) ...
    update-alternatives: using /usr/bin/php8.2 to provide /usr/bin/php (php) in auto mode
    update-alternatives: using /usr/bin/phar8.2 to provide /usr/bin/phar (phar) in auto mode
    update-alternatives: using /usr/bin/phar.phar8.2 to provide /usr/bin/phar.phar (phar.phar) in auto mode
    
    Creating config file /etc/php/8.2/cli/php.ini with new version
    Setting up libaprutil1:arm64 (1.6.1-5ubuntu4) ...
    Setting up libaprutil1-ldap:arm64 (1.6.1-5ubuntu4) ...
    Setting up libaprutil1-dbd-sqlite3:arm64 (1.6.1-5ubuntu4) ...
    Setting up apache2-utils (2.4.52-1ubuntu4.1) ...
    Setting up apache2-bin (2.4.52-1ubuntu4.1) ...
    Setting up libapache2-mod-php8.2 (8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1) ...
    Package apache2 is not configured yet. Will defer actions by package libapache2-mod-php8.2.
    
    Creating config file /etc/php/8.2/apache2/php.ini with new version
    No module matches 
    Setting up apache2 (2.4.52-1ubuntu4.1) ...
    Enabling module mpm_event.
    Enabling module authz_core.
    Enabling module authz_host.
    Enabling module authn_core.
    Enabling module auth_basic.
    Enabling module access_compat.
    Enabling module authn_file.
    Enabling module authz_user.
    Enabling module alias.
    Enabling module dir.
    Enabling module autoindex.
    Enabling module env.
    Enabling module mime.
    Enabling module negotiation.
    Enabling module setenvif.
    Enabling module filter.
    Enabling module deflate.
    Enabling module status.
    Enabling module reqtimeout.
    Enabling conf charset.
    Enabling conf localized-error-pages.
    Enabling conf other-vhosts-access-log.
    Enabling conf security.
    Enabling conf serve-cgi-bin.
    Enabling site 000-default.
    info: Switch to mpm prefork for package libapache2-mod-php8.2
    Module mpm_event disabled.
    Enabling module mpm_prefork.
    info: Executing deferred 'a2enmod php8.2' for package libapache2-mod-php8.2
    Enabling module php8.2.
    Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /lib/systemd/system/apache2.service.
    Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.service → /lib/systemd/system/apache-htcacheclean.service.
    Setting up php8.2 (8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1) ...
    Processing triggers for ufw (0.36.1-4build1) ...
    Processing triggers for man-db (2.10.2-1) ...
    Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
    Processing triggers for php8.2-cli (8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1) ...
    Processing triggers for libapache2-mod-php8.2 (8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1) ...
  8. Remove the PPA repository if it is no longer needed.

This guide is tested on Ubuntu:

Version Code Name
22.04 LTS Jammy Jellyfish
23.10 Mantic Minotaur
24.04 LTS Noble Numbat
Discuss the article:

Comment anonymously. Login not required.