Good news! PHP 8.2 is being actively supported through 31 Dec 2024. After that point, it's advisable to upgrade to the latest version, since the PHP team will only offer security-related support until 31 Dec 2026, at which point PHP 8.2 will be considered "end-of-life".
Update the package list:
sudo apt update
Install PHP 8.2 and common extensions:
sudo apt install php8.2 php8.2-cli php8.2-common php8.2-curl php8.2-mbstring php8.2-mysql php8.2-xml
Install additional extensions as needed:
sudo apt install php8.2-gd php8.2-zip php8.2-bcmath
Check the PHP version:
php -v
You should see output indicating PHP 8.2.x is installed.
Verify installed extensions:
php -m
This will list all installed PHP modules.
Create a test PHP file:
echo '<?php phpinfo();' > /var/www/html/info.php
Access the file in your web browser:
http://your_server_ip/info.php
You should see the PHP information page with details about your installation.