Php – CentOS 8.3 – How to switch a PHP installation from Remi to AppStream

centos8dnfPHPrepository

Currently running PHP 7.4 from Remi. It was a modular dnf installation that replaced PHP 7.2 AppStream packages back when 7.2 was the newest PHP available from CentOS. In other words, Remi packages are the system PHP configured with /etc/php.ini — as opposed to an additional PHP installation that uses /opt/remi/PHP74/php.ini.

Lately however, CentOS AppStream provides PHP 7.4 and I would like to replace Remi packages with equivalent AppStream packages. How should I go about this?

# dnf module list php

CentOS Linux 8 - AppStream
Name             Stream                   Profiles                               Summary
php              7.2 [d]                  common [d], devel, minimal             PHP scripting language
php              7.3                      common [d], devel, minimal             PHP scripting language
php              7.4                      common [d], devel, minimal             PHP scripting language

Remi's Modular repository for Enterprise Linux 8 - x86_64
Name             Stream                   Profiles                               Summary
php              remi-7.2                 common [d], devel, minimal             PHP scripting language
php              remi-7.3                 common [d], devel, minimal             PHP scripting language
php              remi-7.4 [e]             common [d], devel, minimal             PHP scripting language
php              remi-8.0                 common [d], devel, minimal             PHP scripting language

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

I'm familiar with dnf modularity to some extent but I'm doubting it's smart enough to wrangle everything cleanly using a shortcut method of any kind that avoids uninstalling and reinstalling PHP and all its modules from scratch. Suggestions on a path of least resistance would be much appreciated.

Best Answer

(RHEL 8.4+) The same way you switch any other module to a different stream:

dnf module switch-to php:7.4

Note that this will fail if you used any remi packages that are not in the new module stream, and the solution there is to remove PHP entirely from your system manually, and then switch the module stream, and then reinstall PHP.

Related Topic