Keeping your PHP version up to date is essential for taking advantage of new features, performance improvements, and security updates. If you're using PHP 8.2 and want to upgrade to PHP 8.3 on Ubuntu, this guide is for you.
I'll show you the step-by-step process in simple language so you can quickly upgrade your PHP version without hassle.
How to Upgrade PHP 8.2 to 8.3 in Ubuntu
Before upgrading, confirm the PHP version installed on your system:
php -v
If it shows PHP 8.2, you're ready to upgrade to 8.3.
The PHP 8.3 package is available via the Ondřej Surý PPA, a popular repository for PHP versions. Add it to your system:
sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository ppa:ondrej/php
After adding the PPA, update your system's package list:
sudo apt update
Now, install PHP 8.3 by running the following command
sudo apt install -y php8.3
If your application uses specific PHP extensions, install them for PHP 8.3. For example:
sudo apt install php8.3-common php8.3-mysql php8.3-xml php8.3-xmlrpc php8.3-curl php8.3-gd php8.3-imagick php8.3-cli php8.3-dev php8.3-imap php8.3-mbstring php8.3-opcache php8.3-soap php8.3-zip php8.3-intl -y
To make PHP 8.3 the default version, use the update-alternatives
command:
sudo update-alternatives --set php /usr/bin/php8.3
Verify the version again to ensure PHP 8.3 is active:
php -v
Restart Apache or PHP-FPM to apply the changes:
For Apache:
sudo systemctl restart apache2
For PHP-FPM (if using Nginx):
sudo systemctl restart php8.3-fpm
If you're no longer using PHP 8.2, you can safely remove it to free up space:
sudo apt remove -y php8.2
sudo apt autoremove -y
You might also like: