Rocky Linux 9.0でPHP8.0をインストールする方法

環境
OSバージョンの確認

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# cat /etc/redhat-release
Rocky Linux release 9.0 (Blue Onyx)
# cat /etc/redhat-release Rocky Linux release 9.0 (Blue Onyx)
# cat /etc/redhat-release
Rocky Linux release 9.0 (Blue Onyx)

php 8.0のインストール手順

1.システムパッケージを更新します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo dnf upgrade --refresh -y
# sudo dnf upgrade --refresh -y
# sudo dnf upgrade --refresh -y

2.PHP Remiリポジトリをインストールします
CRBを有効にします

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo dnf config-manager --set-enabled crb
# sudo dnf config-manager --set-enabled crb
# sudo dnf config-manager --set-enabled crb

EPELリポジトリをインストールします

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo dnf install \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm \
https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-9.noarch.rpm
# sudo dnf install \ https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm \ https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-9.noarch.rpm
# sudo dnf install \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm \
https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-9.noarch.rpm

Remiリポジトリを有効にします

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-9.rpm -y
# sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-9.rpm -y
# sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-9.rpm -y

3.PHP 8.0(Remi)リポジトリを有効にします
可能なphp依存関係を確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo dnf module list php
Remi's Modular repository for Enterprise Linux 9 - x86_64
Name Stream Profiles Summary
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
# sudo dnf module list php Remi's Modular repository for Enterprise Linux 9 - x86_64 Name Stream Profiles Summary 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
# sudo dnf module list php
Remi's Modular repository for Enterprise Linux 9 - x86_64
Name             Stream              Profiles                              Summary
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

php 8.0リポジトリを有効にします

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo dnf module enable php:remi-8.0 -y
メタデータの期限切れの最終確認: 0:01:57 時間前の 20220724145241秒 に実施しました。
依存関係が解決しました。
============================================================================================================
パッケージ アーキテクチャー バージョン リポジトリー サイズ
============================================================================================================
モジュールストリームの有効化中:
php remi-8.0
トランザクションの概要
============================================================================================================
完了しました!
# sudo dnf module enable php:remi-8.0 -y メタデータの期限切れの最終確認: 0:01:57 時間前の 2022年07月24日 14時52分41秒 に実施しました。 依存関係が解決しました。 ============================================================================================================ パッケージ アーキテクチャー バージョン リポジトリー サイズ ============================================================================================================ モジュールストリームの有効化中: php remi-8.0 トランザクションの概要 ============================================================================================================ 完了しました!
# sudo dnf module enable php:remi-8.0 -y
メタデータの期限切れの最終確認: 0:01:57 時間前の 2022年07月24日 14時52分41秒 に実施しました。
依存関係が解決しました。
============================================================================================================
 パッケージ               アーキテクチャー        バージョン                 リポジトリー             サイズ
============================================================================================================
モジュールストリームの有効化中:
 php                                              remi-8.0

トランザクションの概要
============================================================================================================

完了しました!

4.phpをインストールします
Apache(httpd)ユーザーの場合

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

Nginxユーザーの場合

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

phpの拡張モジュールをインストールします。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo dnf install php-cli php-fpm php-curl php-mysqlnd php-gd php-opcache php-zip php-intl php-common php-bcmath php-imagick php-xmlrpc php-json php-readline php-memcached php-redis php-mbstring php-apcu php-xml php-dom php-redis php-memcached php-memcache
# sudo dnf install php-cli php-fpm php-curl php-mysqlnd php-gd php-opcache php-zip php-intl php-common php-bcmath php-imagick php-xmlrpc php-json php-readline php-memcached php-redis php-mbstring php-apcu php-xml php-dom php-redis php-memcached php-memcache
# sudo dnf install php-cli php-fpm php-curl php-mysqlnd php-gd php-opcache php-zip php-intl php-common php-bcmath php-imagick php-xmlrpc php-json php-readline php-memcached php-redis php-mbstring php-apcu php-xml php-dom php-redis php-memcached php-memcache

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# php --version
PHP 8.0.21 (cli) (built: Jul 6 2022 10:13:53) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.21, Copyright (c) Zend Technologies
with Zend OPcache v8.0.21, Copyright (c), by Zend Technologies
# php --version PHP 8.0.21 (cli) (built: Jul 6 2022 10:13:53) ( NTS gcc x86_64 ) Copyright (c) The PHP Group Zend Engine v4.0.21, Copyright (c) Zend Technologies with Zend OPcache v8.0.21, Copyright (c), by Zend Technologies
# php --version
PHP 8.0.21 (cli) (built: Jul  6 2022 10:13:53) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.21, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.21, Copyright (c), by Zend Technologies

phpモジュールを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# php -m
[PHP Modules]
apcu
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
igbinary
imagick
intl
json
libxml
mbstring
memcache
memcached
msgpack
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
readline
redis
Reflection
session
SimpleXML
sockets
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache
# php -m [PHP Modules] apcu bcmath bz2 calendar Core ctype curl date dom exif fileinfo filter ftp gd gettext hash iconv igbinary imagick intl json libxml mbstring memcache memcached msgpack mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql pdo_sqlite Phar readline redis Reflection session SimpleXML sockets sodium SPL sqlite3 standard tokenizer xml xmlreader xmlrpc xmlwriter xsl Zend OPcache zip zlib [Zend Modules] Zend OPcache
# php -m
[PHP Modules]
apcu
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
igbinary
imagick
intl
json
libxml
mbstring
memcache
memcached
msgpack
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
readline
redis
Reflection
session
SimpleXML
sockets
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

 

Rocky Linux 9

Posted by arkgame