AlmaLinux 8でphp8.1をインストールする方法

環境

# cat /etc/redhat-release
AlmaLinux release 8.4 (Electric Cheetah)

操作方法
1.リポジトリを追加

# sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
# sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm

2.リポジトリを確認

# dnf repolist
repo id                    repo の名前
appstream                  AlmaLinux 8 - AppStream
baseos                     AlmaLinux 8 - BaseOS
docker-ce-stable           Docker CE Stable - x86_64
epel                       Extra Packages for Enterprise Linux 8 - x86_64
epel-modular               Extra Packages for Enterprise Linux Modular 8 - x86_64
extras                     AlmaLinux 8 - Extras
mysql-connectors-community MySQL Connectors Community
mysql-tools-community      MySQL Tools Community
mysql80-community          MySQL 8.0 Community Server
remi-modular               Remi's Modular repository for Enterprise Linux 8 - x86_64
remi-safe                  Safe Remi's RPM repository for Enterprise Linux 8 - x86_64
teamviewer                 TeamViewer - x86_64

3.phpのバージョンを確認

# sudo dnf module list php
AlmaLinux 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        common [d], devel, minimal    PHP scripting language
php      remi-8.0 [e]    common [d], devel, minimal    PHP scripting language
php      remi-8.1        common [d], devel, minimal    PHP scripting language

ヒント: [d]efault, [e]nabled, [x]disabled, [i]nstalled

4.現行phpバージョンを確認

# php -v
PHP 8.0.11 (cli) (built: Sep 21 2021 17:07:44) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.11, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.11, Copyright (c), by Zend Technologies

5.php8.0バージョンをリセットしてphp8.1バージョンを切り替える

# dnf module -y reset php
# dnf module -y enable php:remi-8.1

6.php8.1をインストール

# sudo dnf install php php-cli

バージョンを確認

# php -v
PHP 8.1.0RC5 (cli) (built: Oct 27 2021 00:20:44) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.0RC5, Copyright (c), by Zend Technologies

 

AlmaLinux

Posted by arkgame