Dnf install php vs dnf module install php:7.2

Trying to climb a steep learning curve jumping from CentOS 7 to Rocky, with CentOS going away this December. What’s the difference between install php and module install php:7.2. Module install doesn’t appear to actually install php, but only php related packages? The module install doesn’t include the following

Installing:
php x86_64 7.2.24-1.module+el8.4.0+413+c9202dda appstream 1.5 M

[root@finaidrocky marc]# dnf module install php:7.2
Last metadata expiration check: 2:04:30 ago on Sun 31 Oct 2021 03:08:01 PM PDT.
Dependencies resolved.
============================================================================================================================================================
 Package                             Architecture              Version                                                   Repository                    Size
============================================================================================================================================================
Installing group/module packages:
 php-cli                             x86_64                    7.2.24-1.module+el8.4.0+413+c9202dda                      appstream                    3.1 M
 php-common                          x86_64                    7.2.24-1.module+el8.4.0+413+c9202dda                      appstream                    660 k
 php-fpm                             x86_64                    7.2.24-1.module+el8.4.0+413+c9202dda                      appstream                    1.6 M
 php-json                            x86_64                    7.2.24-1.module+el8.4.0+413+c9202dda                      appstream                     72 k
 php-mbstring                        x86_64                    7.2.24-1.module+el8.4.0+413+c9202dda                      appstream                    579 k
 php-xml                             x86_64                    7.2.24-1.module+el8.4.0+413+c9202dda                      appstream                    187 k
Installing dependencies:
 nginx-filesystem                    noarch                    1:1.14.1-9.module+el8.4.0+542+81547229                    appstream                     23 k

Transaction Summary
============================================================================================================================================================
Install  7 Packages
[root@finaidrocky marc]# dnf install php
Last metadata expiration check: 2:05:19 ago on Sun 31 Oct 2021 03:08:01 PM PDT.
Dependencies resolved.
============================================================================================================================================================
 Package                             Architecture              Version                                                   Repository                    Size
============================================================================================================================================================
Installing:
 php                                 x86_64                    7.2.24-1.module+el8.4.0+413+c9202dda                      appstream                    1.5 M
Installing dependencies:
 nginx-filesystem                    noarch                    1:1.14.1-9.module+el8.4.0+542+81547229                    appstream                     23 k
 php-cli                             x86_64                    7.2.24-1.module+el8.4.0+413+c9202dda                      appstream                    3.1 M
 php-common                          x86_64                    7.2.24-1.module+el8.4.0+413+c9202dda                      appstream                    660 k
Installing weak dependencies:
 php-fpm                             x86_64                    7.2.24-1.module+el8.4.0+413+c9202dda                      appstream                    1.6 M

Transaction Summary
============================================================================================================================================================
Install  5 Packages

Looking at man dnf and Chapter 2. Introduction to modules Red Hat Enterprise Linux 8 | Red Hat Customer Portal

  • dnf install php installs package ‘php’ and dependencies
  • dnf module install php installs packages that are in default profile of active module stream ‘php’ (and their dependencies)
  • dnf install @php is same as dnf module install php

The php:7.2 is probably active by default, so there should be no need to state the “7.2”.
To change active stream: Chapter 6. Managing versions of Application Stream content Red Hat Enterprise Linux 8 | Red Hat Customer Portal

What does each profile contain? dnf module info --profile php:7.2

The package ‘php’ does not contain many files: dnf repoquery --list php
but it has dependencies: dnf repoquery --requires --resolve php

(Some “meta” packages have only dependencies, almost like “yum groups” and “module profiles”.)

1 Like

Is it correct to think, dnf module install xxx installs packages that support/work with the main application package, which is done separately by dnf install main-application-package (php in this example)?

I don’t know what to think.

A module (profile) is clearly a list of packages. Say xxx = [aaa, bbb, ccc]
(A yum group is similarly a list and environment group is a list of yum groups.)
Therefore, dnf install @xxx is same as dnf install aaa bbb ccc

One can add exclude: dnf install @xxx --exclude=bbb means dnf install aaa ccc
If you have package ddd that requires aaa bbb ccc, then
dnf install ddd installs all four (if they are not already installed), but
dnf install ddd --exclude=bbb would not be possible, because ddd requires bbb.

Why doesn’t profile ‘common’ of module ‘php:7.2’ include package ‘php’? I have no idea.
There is even profile ‘minimal’ that has … only two packages?
Perhaps package ‘php’ is not essential for use of PHP?

1 Like

Historically, in previous versions, the “php” package was providing “mod_php” (Apache HTTP Serveur module).

It is now mostly a meta-package pulling most commonly used SAPI (cli, fpm) and extensions.

NOTICE: the php:7.2 stream have reached its end of live in May (7.3 in Nov), consider using php:7.4 which will be maintained for the whole distribution life.

P.S. in 8 mod_php is still there but only if you switch to “prefork” mode, in 9 it will be really removed.

3 Likes

Hi whichiso,
In my opinion the biggest difference between RHEL 7 and 8 is the use of Application streams. This has made life much easier to manage and use the latest version of applications like php etc. In RHEL 7 we keep struggling to manage these via Software Collections.

In RHEL 8 ( and of course in Rocky ) PHP 7.2 is default profile. If want to use PHP 7.4 it is just matter of two commands

yum module enable php:7.4

yum module install php:7.4/devel

1 Like