Logo

How to Install PHP 8.2 on Ubuntu 24.04

May 02, 2024

To install PHP 8.2 on Ubuntu 24.04, follow these steps:

Step 1 : Update your package list to ensure you have the latest information about available packages.

sudo apt update

Step 2 : Add the PHP repository maintained by Ondřej Surý, which provides the latest PHP versions.

sudo add-apt-repository ppa:ondrej/php

Step 3 : Update your package list again to include the new PHP repository.

sudo apt update

Step 4 : Install PHP 8.2 core packages, including PHP CLI and PHP FPM.

sudo apt install php8.2 php8.2-cli php8.2-fpm

Step 5 : Install commonly used PHP extensions. These extensions provide additional functionality for PHP applications.

sudo apt install php8.2-{mysql,curl,xsl,gd,common,xml,zip,xsl,soap,bcmath,mbstring}

- php8.2-mysql: MySQL database connectivity.

- php8.2-curl: Client-side URL Library for PHP.

- php8.2-xsl: XSL module for PHP.

- php8.2-gd: GD Graphics Library for PHP.

- php8.2-common: Common files for PHP.

- php8.2-xml: XML module for PHP.

- php8.2-zip: Zip module for PHP.

- php8.2-soap: SOAP module for PHP.

- php8.2-bcmath: Arbitrary precision mathematics module for PHP.

- php8.2-mbstring: Multibyte string module for PHP.

Step 6 : Verify that PHP 8.2 is installed correctly and check its version.

php -v

Congratulations! You have successfully installed PHP 8.2 on your Ubuntu 24.04 system.

Recommended