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.
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.