🧾 Introduction
There may be times when you need to remove a specific PHP version from your AlmaLinux 9 server—for example, to reduce clutter or remove unsupported/unused versions. This guide shows how to do so using the command line with dnf
.
🛠️ Procedure
To remove all PHP packages related to a specific version, use the following command format. Replace xx
with the appropriate PHP version number (e.g., 81
for PHP 8.1).
🔹 For EA4 Packages (cPanel):
Run the following to remove EasyApache 4 PHP packages:
dnf remove ea-phpxx\*
📌 Example: To remove PHP 7.4:
dnf remove ea-php74\*
🔸 For CloudLinux alt-php Packages:
If you’re on CloudLinux 9 with alt-php, use:
dnf remove alt-phpxx\*
📌 Example: To remove alt-php 8.0:
dnf remove alt-php80\*
✅ Post-Removal Steps
After removing PHP, you should:
🔍 Check Installed PHP Versions
dnf list installed | grep php
🔧 Restart Relevant Services
- For Apache:
systemctl restart httpd
- For LiteSpeed:
systemctl restart lsws
🌐 Verify Removal
Run:
php -v
This should now reflect the currently active PHP version, or show an error if none are installed via the CLI.
🧠 Note
If you’re using MultiPHP Manager in WHM, make sure to update default PHP version settings or handlers after removal.