How to Install PHP 8.2 on Ubuntu 26.04

To install PHP 8.2 on Ubuntu 26.04, Ubuntu’s repos only ship 8.5, so 8.2 needs packages.sury.org. ppa:ondrej/php is merging into Sury; on 26.04 that is the canonical source.

Step 1 : Update.

Step 2 : Install the packages the repository setup needs.

Step 3 : Download the repository keyring.

Step 4 : Install the keyring.

Step 5 : Add the PHP repository.

Step 6 : Update again.

Step 7 : Install PHP 8.2, CLI, and PHP-FPM.

Step 8 : Install common extensions. Common extensions: mysql, curl, gd / imagick, xml / xsl / soap, zip, mbstring, bcmath. gettext is in php8.2-common.

Step 9 : Point the php command at 8.2 (26.04 already defaults to 8.5 if that package is installed).

Step 10 : Check the version.

You have installed PHP 8.2 on Ubuntu 26.04.