apt and apt-get are the package management tools for Ubuntu and other Debian-based Linux distributions. It allows you to easily install and updates packages that are hosted in the default repositories.

The repositories contain most of the commonly-used packages for most people and for the versions officially supported by the distributions. If you need packages or software that are not available in the default apt/apt-get repositories, you can look into third-party or PPA (Personal Package Archives) repositories.

You can search for third-party repositories in launchpad or from any vendor's website and add them to your apt/apt-get repositories using add-apt-repository tool. You will then be able to install and update your third-party packages using apt/apt-get as you normally would.

Steps to add PPA repository for apt 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: 
    PPA publishes dbgsym, you may need to include 'main/debug' component
    Repository: 'deb https://ppa.launchpadcontent.net/ondrej/php/ubuntu/ jammy main'
    Description:
    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
    
    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.
    ##### snipped
  4. Press [ENTER] to confirm and continue.
    Adding deb entry to /etc/apt/sources.list.d/ondrej-ubuntu-php-jammy.list
    Adding disabled deb-src entry to /etc/apt/sources.list.d/ondrej-ubuntu-php-jammy.list
    Adding key to /etc/apt/trusted.gpg.d/ondrej-ubuntu-php.gpg with fingerprint 14AA40EC0831756756D7F66C4F4EA0AAE5267A6C
    Get:1 http://ports.ubuntu.com/ubuntu-ports jammy-security InRelease [110 kB]
    Hit:2 http://us.ports.ubuntu.com/ubuntu-ports jammy InRelease          
    Get:3 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy InRelease [23.9 kB]
    Get:4 http://us.ports.ubuntu.com/ubuntu-ports jammy-updates InRelease [114 kB]
    Get:5 http://ports.ubuntu.com/ubuntu-ports jammy-proposed InRelease [270 kB]
    Get:6 http://ports.ubuntu.com/ubuntu-ports jammy-security/main arm64 DEP-11 Metadata [13.1 kB]
    Get:7 http://ports.ubuntu.com/ubuntu-ports jammy-security/universe arm64 DEP-11 Metadata [11.8 kB]
    Get:8 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy/main arm64 Packages [97.6 kB]
    Get:9 http://us.ports.ubuntu.com/ubuntu-ports jammy-backports InRelease [99.8 kB]
    Get:10 http://ports.ubuntu.com/ubuntu-ports jammy-proposed/main arm64 DEP-11 Metadata [5,716 B]
    Get:11 http://us.ports.ubuntu.com/ubuntu-ports jammy-updates/main arm64 Packages [570 kB]
    Get:12 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy/main Translation-en [30.7 kB]
    Get:13 http://us.ports.ubuntu.com/ubuntu-ports jammy-updates/main arm64 DEP-11 Metadata [92.9 kB]
    Get:14 http://us.ports.ubuntu.com/ubuntu-ports jammy-updates/universe arm64 Packages [387 kB]
    Get:15 http://us.ports.ubuntu.com/ubuntu-ports jammy-updates/universe arm64 DEP-11 Metadata [243 kB]
    Get:16 http://us.ports.ubuntu.com/ubuntu-ports jammy-backports/universe arm64 DEP-11 Metadata [12.4 kB]
    Fetched 2,082 kB in 3s (624 kB/s)                                      
    Reading package lists... Done
  5. Update package list for apt.
    $ sudo apt update
    Hit:1 http://ports.ubuntu.com/ubuntu-ports jammy-security InRelease    
    Hit:2 http://ports.ubuntu.com/ubuntu-ports jammy-proposed InRelease    
    Hit:3 http://us.ports.ubuntu.com/ubuntu-ports jammy InRelease          
    Hit:4 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy InRelease
    Hit:5 http://us.ports.ubuntu.com/ubuntu-ports jammy-updates InRelease
    Hit:6 http://us.ports.ubuntu.com/ubuntu-ports jammy-backports InRelease
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    4 packages can be upgraded. Run 'apt list --upgradable' to see them.
  6. Upgrade installed packages based on 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 made 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 PPA repository if 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.