Frequently Asked Question
PHP Update or Downgrade
Last Updated 53 minutes ago
To update or downgrade PHP on a RHEL-based distribution (such as AlmaLinux, Rocky Linux, or CentOS Stream) using the Remi repository, follow the steps below.
Prerequisites
Before changing PHP versions, ensure the CodeReady Builder (CRB) repository is enabled and the Remi repository is installed.
sudo dnf config-manager --set-enabled crb
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm
- Enable CRB and install Remi:
Updating PHP (e.g., to PHP 8.5)
To switch to a newer version of PHP, you must reset the current module stream and enable the desired version.
sudo dnf module reset php
sudo dnf module enable php:remi-8.5
sudo dnf update php*
- Reset the current PHP module:
- Enable the new PHP version (e.g., 8.5):
- Update all PHP packages:
Downgrading PHP (e.g., to PHP 8.3)
To revert to an older version, follow the same module reset process but enable the older version stream.
sudo dnf module reset php
sudo dnf module enable php:remi-8.3
sudo dnf distro-sync
- Reset the current PHP module:
- Enable the older PHP version (e.g., 8.3):
- Synchronise the system to install the downgraded packages:
Important Notes
sudo systemctl restart php-fpm
sudo systemctl restart httpd # or nginx
php -v
- Web Server Restart: After changing PHP versions, you must restart your web server (e.g., Apache or Nginx) and PHP-FPM service to apply the changes.
- Module Dependencies: If you have specific PHP extensions installed (such as
php-mysqlnd,php-gd, etc.), ensure they are available for the new version. Thednf updateordnf distro-synccommands usually handle this, but you may need to manually install missing extensions if they are not part of the base module stream. - Verify Version: Check the active PHP version after the process is complete:
``
