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

環境

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# cat /etc/redhat-release
AlmaLinux release 8.4 (Electric Cheetah)
# cat /etc/redhat-release AlmaLinux release 8.4 (Electric Cheetah)
# cat /etc/redhat-release
AlmaLinux release 8.4 (Electric Cheetah)

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# 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
# 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
# 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.リポジトリを確認

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# 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
# 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
# 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のバージョンを確認

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# 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
# 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
# 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バージョンを確認

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# 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
# 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
# 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バージョンを切り替える

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# dnf module -y reset php
# dnf module -y enable php:remi-8.1
# dnf module -y reset php # dnf module -y enable php:remi-8.1
# dnf module -y reset php
# dnf module -y enable php:remi-8.1

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo dnf install php php-cli
# sudo dnf install php php-cli
# sudo dnf install php php-cli

バージョンを確認

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# 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
# 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
# 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