CentOS Stream 8にphp7.4をインストールする

環境
# cat /etc/redhat-release
CentOS Stream release 8

インストールの方法
1.リポジトリを追加します

# sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

2.システムパッケージをアップデートします
# sudo dnf update

3.有効になっている PHP のバージョンを確認します

#  dnf module list php
CentOS Stream 8 - AppStream
Name     Stream         Profiles                       Summary
php      7.2 [d][e]     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       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. 他バージョンが有効な場合は一旦リセットします
# dnf module reset php

5.php7.4をインストールします

# dnf module enable php:7.4
# dnf module -y install php:7.4/common

6.バージョンを確認します

# php -v
PHP 7.4.19 (cli) (built: May  4 2021 11:06:37) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

7.動作確認

# echo "<?php echo 'PHP 7.4 study skill'.\"\n\"; ?>" > sample.php
# php sample.php
PHP 7.4 study skill

 

CentOS Stream 8

Posted by arkgame