DEV Community

Seong Bae
Seong Bae

Posted on

Upgrade to PHP 8.2

Below commands will install or upgrade your PHP to 8.2 on Ubuntu. I created this post so that I can use this as a reference for myself and maybe others as well.

# Update your system
sudo dpkg -l | grep php | tee packages.txt
sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt update

# Install php 8.2 and other required modules
sudo apt install php8.2 php8.2-cli php8.2-{bz2,curl,mbstring,intl,xml,mysql}

sudo apt install php8.2-fpm
# OR
# sudo apt install libapache2-mod-php8.2

sudo a2enconf php8.2-fpm

# When upgrading from older PHP version:
sudo a2disconf php8.1-fpm

## Remove old packages if needed
sudo apt purge php8.1*

sudo a2enmod php8.2
sudo service apache2 restart
Enter fullscreen mode Exit fullscreen mode

Also, after upgrading from 8.1 to 8.2, I was getting error message when browsing to a local site

Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.2.0".
Enter fullscreen mode Exit fullscreen mode

This issue came from apache still using 8.1. I was able to resolve this by entiring removing php 8.1.

sudo apt remove php8.1-*
Enter fullscreen mode Exit fullscreen mode

Make sure to restart apache after removing old php.

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free โ†’