dnf upgrade --refresh -y
dnf install -y http://ftp.riken.jp/Linux/remi/enterprise/remi-release-9.rpm

之后可以用以下命令查看存在的木块

dnf module list
#输出
Last metadata expiration check: 0:06:00 ago on Fri May  5 09:54:43 2023.
Rocky Linux 9 - AppStream
Name                                    Stream                                 Profiles                                                            Summary                                                                            
maven                                   3.8                                    common [d]                                                          Java project management and project comprehension tool                             
nodejs                                  18                                     common [d], development, minimal, s2i                               Javascript runtime                                                                 
php                                     8.1                                    common [d], devel, minimal                                          PHP scripting language                                                             
ruby                                    3.1                                    common [d]                                                          An interpreter of object-oriented scripting language                               

Remi's Modular repository for Enterprise Linux 9 - aarch64
Name                                    Stream                                 Profiles                                                            Summary                                                                            
composer                                2                                      common [d]                                                          Dependency Manager for PHP                                                         
memcached                               remi                                   common [d]                                                          High Performance, Distributed Memory Object Cache                                  
php                                     remi-7.4                               common [d], devel, minimal                                          PHP scripting language                                                             
php                                     remi-8.0                               common [d], devel, minimal                                          PHP scripting language                                                             
php                                     remi-8.1                               common [d], devel, minimal                                          PHP scripting language                                                             
php                                     remi-8.2                               common [d], devel, minimal                                          PHP scripting language                                                             
redis                                   remi-6.0                               common                                                              Redis persistent key-value database                                                
redis                                   remi-6.2                               common [d]                                                          Redis persistent key-value database                                                
redis                                   remi-7.0                               common [d]                                                          Redis persistent key-value database                                                
redis                                   remi-7.2                               common [d]                                                          Redis persistent key-value database                                                

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

可以看到默认php是8.1只要使用以下命令替换默认的,即可安装指定的PHP版本

dnf module enable php:remi-7.4

安装已经替换默认的php版本

dnf -y install php-fpm php-cli php-common php-gd php-mbstring php-mcrypt php-mysql php-pdo php-redis

安装指定版本的php

dnf -y install php74-php php74-php-fpm php74-php-cli php74-php-common php74-php-gd php74-php-mbstring php74-php-mcrypt php74-php-mysql php74-php-pdo php74-php-redis