103 words, 1 min read

After upgrading PHP on a Debian or Ubuntu system, it’s a good idea to clean up old PHP versions once you’ve confirmed the new installation works correctly. This helps reduce clutter and avoids accidentally running outdated binaries or services.

You can remove all packages belonging to a specific PHP version using apt purge with a wildcard:

sudo apt purge '^php8.3.*'

This command purges all installed PHP 8.3 packages, including configuration files. Adjust the version number to match the PHP release you want to remove.

As a final step, you may want to run:

sudo apt autoremove

to clean up any remaining unused dependencies.