conohaVPS(CentOS Stream9)にPHPをインストール

PHP
この記事が対象とする環境
CentOS Stream 9
PHP 8.2

PHPインストール

Remiを使用してPHPをインストールします。Remiを使用するにはEPELも必要なのであわせてインストールします。

  • EPEL(イーペル)
    サードパーティ製のリポジトリ
  • Remi(レミ)
    サードパーティ製のリポジトリ

EPEL(イーペル)

管理者ユーザーでログインしていない場合に切り替えます。パスワードの入力を求められるので、rootユーザーのパスワードを入力します。

su
Password: 

EPELインストール

dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
Last metadata expiration check: 0:13:50 ago on Wed 07 Jun 2023 03:23:58 PM JST.
epel-release-latest-9.noarch.rpm                                                                                                20 kB/s |  18 kB     00:00    
Dependencies resolved.
===============================================================================================================================================================
 Package                                 Architecture                      Version                               Repository                               Size
===============================================================================================================================================================
Upgrading:
 epel-release                            noarch                            9-5.el9                               @commandline                             18 k

Transaction Summary
===============================================================================================================================================================
Upgrade  1 Package

Total size: 18 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                       1/1 
  Upgrading        : epel-release-9-5.el9.noarch                                                                                                           1/2 
  Running scriptlet: epel-release-9-5.el9.noarch                                                                                                           1/2 
  Cleanup          : epel-release-8-19.el8.noarch                                                                                                          2/2 
  Running scriptlet: epel-release-8-19.el8.noarch                                                                                                          2/2 
  Verifying        : epel-release-9-5.el9.noarch                                                                                                           1/2 
  Verifying        : epel-release-8-19.el8.noarch                                                                                                          2/2 
Installed products updated.

Upgraded:
  epel-release-9-5.el9.noarch                                                                                                                                  

Complete!

Remi(レミ)

Remiインストール

dnf install -y https://rpms.remirepo.net/enterprise/remi-release-9.rpm
Last metadata expiration check: 2:42:38 ago on Wed 07 Jun 2023 12:55:24 PM JST.
remi-release-9.rpm                                                                                                              27 kB/s |  28 kB     00:01    
Dependencies resolved.
===============================================================================================================================================================
 Package                                Architecture                     Version                                  Repository                              Size
===============================================================================================================================================================
Installing:
 remi-release                           noarch                           9.1-2.el9.remi                           @commandline                            28 k

Transaction Summary
===============================================================================================================================================================
Install  1 Package

Total size: 28 k
Installed size: 27 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                       1/1 
  Installing       : remi-release-9.1-2.el9.remi.noarch                                                                                                    1/1 
  Verifying        : remi-release-9.1-2.el9.remi.noarch                                                                                                    1/1 
Installed products updated.

Installed:
  remi-release-9.1-2.el9.remi.noarch                                                                                                                           

Complete!

インストール可能なバージョンを確認

28行目でPHP8.2がインストール可能なことを確認できます。

dnf module list php
Remi's Modular repository for Enterprise Linux 9 - x86_64                                                                      554  B/s | 833  B     00:01    
Remi's Modular repository for Enterprise Linux 9 - x86_64                                                                      3.0 MB/s | 3.1 kB     00:00    
Importing GPG key 0x478F8947:
 Userid     : "Remi's RPM repository (https://rpms.remirepo.net/) "
 Fingerprint: B1AB F71E 14C9 D748 97E1 98A8 B195 27F1 478F 8947
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el9
Is this ok [y/N]: y
Remi's Modular repository for Enterprise Linux 9 - x86_64                                                                      350 kB/s | 885 kB     00:02    
Safe Remi's RPM repository for Enterprise Linux 9 - x86_64                                                                     573  B/s | 833  B     00:01    
Safe Remi's RPM repository for Enterprise Linux 9 - x86_64                                                                     3.0 MB/s | 3.1 kB     00:00    
Importing GPG key 0x478F8947:
 Userid     : "Remi's RPM repository (https://rpms.remirepo.net/) "
 Fingerprint: B1AB F71E 14C9 D748 97E1 98A8 B195 27F1 478F 8947
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el9
Is this ok [y/N]: y
Safe Remi's RPM repository for Enterprise Linux 9 - x86_64                                                                     430 kB/s | 1.1 MB     00:02    
Last metadata expiration check: 0:00:01 ago on Wed 07 Jun 2023 03:40:17 PM JST.
CentOS Stream 9 - AppStream
Name                         Stream                           Profiles                                           Summary                                       
php                          8.1                              common [d], devel, minimal                         PHP scripting language                        

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                        
php                          remi-8.2                         common [d], devel, minimal                         PHP scripting language                        

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

Remiでインストールするバージョンを指定

dnf module enable php:remi-8.2
Last metadata expiration check: 0:01:05 ago on Wed 07 Jun 2023 03:40:17 PM JST.
Dependencies resolved.
===============================================================================================================================================================
 Package                               Architecture                         Version                                Repository                             Size
===============================================================================================================================================================
Enabling module streams:
 php                                                                        remi-8.2                                                                          

Transaction Summary
===============================================================================================================================================================

Is this ok [y/N]: y
Complete!

PHPインストール

dnf install php php-cli php-common
Last metadata expiration check: 0:01:36 ago on Wed 07 Jun 2023 03:40:17 PM JST.
Dependencies resolved.
==============================================================================================
 Package                                  Architecture  Version           Repository     Size
==============================================================================================
Installing:
 php                                      x86_64        8.2.7-2.el9.remi  remi-modular  1.8 M
 php-cli                                  x86_64        8.2.7-2.el9.remi  remi-modular  5.3 M
 php-common                               x86_64        8.2.7-2.el9.remi  remi-modular  838 k
Installing dependencies:
 apr                                      x86_64        1.7.0-11.el9      appstream     123 k
 apr-util                                 x86_64        1.6.1-20.el9      appstream      95 k
 apr-util-bdb                             x86_64        1.6.1-20.el9      appstream      14 k
 httpd-core                               x86_64        2.4.57-2.el9      appstream     1.5 M
 httpd-filesystem                         noarch        2.4.57-2.el9      appstream      15 k
 httpd-tools                              x86_64        2.4.57-2.el9      appstream      84 k
 libsodium                                x86_64        1.0.18-8.el9      epel          161 k
 oniguruma5php                            x86_64        6.9.8-1.el9.remi  remi-safe     219 k
Installing weak dependencies:
 apr-util-openssl                         x86_64        1.6.1-20.el9      appstream      16 k
 php-fpm                                  x86_64        8.2.7-2.el9.remi  remi-modular  1.8 M
 php-mbstring                             x86_64        8.2.7-2.el9.remi  remi-modular  574 k
 php-opcache                              x86_64        8.2.7-2.el9.remi  remi-modular  601 k
 php-pdo                                  x86_64        8.2.7-2.el9.remi  remi-modular  117 k
 php-sodium                               x86_64        8.2.7-2.el9.remi  remi-modular   62 k
 php-xml                                  x86_64        8.2.7-2.el9.remi  remi-modular  203 k

Transaction Summary
==============================================================================================
Install  18 Packages

Total download size: 14 M
Installed size: 66 M
Is this ok [y/N]: y
Downloading Packages:
(1/18): apr-util-1.6.1-20.el9.x86_64.rpm                         1.1 MB/s |  95 kB     00:00
(2/18): apr-util-bdb-1.6.1-20.el9.x86_64.rpm                     146 kB/s |  14 kB     00:00
~ 省略 ~
(18/18): oniguruma5php-6.9.8-1.el9.remi.x86_64.rpm               861 kB/s | 219 kB     00:00
--------------------------------------------------------------------------------------------
Total                                                            2.8 MB/s |  14 MB     00:04
Remi's Modular repository for Enterprise Linux 9 - x86_64        3.0 MB/s | 3.1 kB     00:00
Importing GPG key 0x478F8947:
 Userid     : "Remi's RPM repository (https://rpms.remirepo.net/) "
 Fingerprint: B1AB F71E 14C9 D748 97E1 98A8 B195 27F1 478F 8947
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el9
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                               1/1 
  Running scriptlet: php-common-8.2.7-2.el9.remi.x86_64           1/18 
  Installing       : php-common-8.2.7-2.el9.remi.x86_64           1/18 
  Running scriptlet: httpd-filesystem-2.4.57-2.el9.noarch         2/18 
  Installing       : httpd-filesystem-2.4.57-2.el9.noarch         2/18 
~ 省略 ~
  Verifying        : oniguruma5php-6.9.8-1.el9.remi.x86_64       18/18 
Installed products updated.

Installed:
  apr-1.7.0-11.el9.x86_64                 apr-util-1.6.1-20.el9.x86_64           apr-util-bdb-1.6.1-20.el9.x86_64      apr-util-openssl-1.6.1-20.el9.x86_64  
  httpd-core-2.4.57-2.el9.x86_64          httpd-filesystem-2.4.57-2.el9.noarch   httpd-tools-2.4.57-2.el9.x86_64       libsodium-1.0.18-8.el9.x86_64         
  oniguruma5php-6.9.8-1.el9.remi.x86_64   php-8.2.7-2.el9.remi.x86_64            php-cli-8.2.7-2.el9.remi.x86_64       php-common-8.2.7-2.el9.remi.x86_64    
  php-fpm-8.2.7-2.el9.remi.x86_64         php-mbstring-8.2.7-2.el9.remi.x86_64   php-opcache-8.2.7-2.el9.remi.x86_64   php-pdo-8.2.7-2.el9.remi.x86_64       
  php-sodium-8.2.7-2.el9.remi.x86_64      php-xml-8.2.7-2.el9.remi.x86_64       

Complete!
[root@157-7-193-0 /]# php -v
PHP 8.2.7 (cli) (built: Jun  6 2023 21:28:56) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.2.7, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.7, Copyright (c), by Zend Technologies

札幌在住エンジニア。JavaやPHPやWordPressを中心とした記事が中心です。

【SE歴】四半世紀以上
【Backend】php / java(spring) / c# / AdobeFlex / c++ / VB / cobol
【Frontend】 vue.js / jquery他 / javascript / html / css
【DB】oracle / mysql / mariadb / sqlite
【infrastructure】aws / oracle / gcp
【license】aws(saa-c03) / oracle master / XML Master / Sun Certified Programmer for the Java 2 Platform 1.4

Nobelをフォローする
PHP
Nobelをフォローする

コメント

タイトルとURLをコピーしました