0

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.

chewykernel
  • 1
  • 1
  • 3

2 Answers2

0

(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.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • dnf module: error: argument : invalid choice: 'switch-to' (choose from 'disable', 'enable', 'info', 'install', 'list', 'provides', 'remove', 'repoquery', 'reset', 'update') – Remi Collet May 26 '21 at 13:54
  • @RemiCollet Are you on RHEL 8.3 or later? Or maybe it's 8.4, I haven't checked an 8.3 system. – Michael Hampton May 26 '21 at 18:22
  • I just checked and it is indeed new in 8.4, not present in 8.3 and earlier. It basically switches the module stream and does a distro-sync. – Michael Hampton May 26 '21 at 18:34
  • Yeah, at first "switch-to" sounded like something from a different distro. Searching didn't turn up anything until I dug deeper in RHEL docs. CentOS isn't upgrading to 8.4 yet AFAIK, if it ships at all with its EOL around the corner. – chewykernel May 27 '21 at 20:56
0

Revised answer...

dnf does indeed have a satisfactory short method that avoids the tedium of removing and reinstalling PHP from scratch. There's plenty of prep to do but the essentials involve three commands.

dnf module reset php
dnf module install php:7.4
dnf distro-sync

As a heads up before running dnf distro-sync, leave the remi-modular repo enabled to retain certain modules such as php-pecl-redis5, php-pecl-msgpack, php-pecl-imagick and so on (see below).

After a slew of transactions with no errors aside from *.rpmnew files leaving existing *.conf files intact, I ran a couple extra commands out of curiosity.

# dnf upgrade php\*
Last metadata expiration check: 1:09:55 ago on Fri 28 May 2021 02:05:10 PM EDT.
Dependencies resolved.
Nothing to do.
Complete!

# dnf remove --duplicates
Last metadata expiration check: 1:10:37 ago on Fri 28 May 2021 02:05:10 PM EDT.
Error: No duplicated packages found for removal.

Everything starts and runs as before with no obvious problems. There's just one rub to be aware of: a handful of modules from remi-modular were not replaced by CentOS or EPEL repos, which is best explained in this Serverfault Q&A. Take note of Issue 75 and @RemiCollet's interesting comments.

Noteworthy is @MichaelHampton's previous answer about switching streams. If RHEL is release 8.4 (and presumably the same for 8.4 releases of CentOS & Stream, AlmaLinux and Rocky Linux), dnf module switch-to php:7.4 is a newer alternative to dnf module reset combined with dnf distro-sync.

chewykernel
  • 1
  • 1
  • 3