Troubleshooting & Tools for PHP¶
Updated June 21, 2025
Remove old versions of PHP¶
sudo apt purge php7.4*
sudo apt autoclean && apt autoremove -y
Check which version and modules are installed¶
dpkg --list | grep php
sudo update-alternatives --list php
Change which version should be running¶
sudo update-alternatives --config php
Confirm which version is running¶
php --version
Install PHP and some extensions¶
sudo add-apt-repository ppa:ondrej/php && add-apt-repository ppa:ondrej/apache2
sudo apt install php8.4 libapache2-mod-php8.4 libapache2-mod-fcgid -y
sudo apt install -y php8.4-{common,fpm,curl,xml,cli,mysql,cgi,zip,gmp,bcmath,gd,intl,ssh2,pdo,opcache,dev,apcu,sockets}