DockerでのLAMP環境構築手順(Amazon Linux 2/PHP8.1(Laravel9)) ③PHP8.1系のインストール(全8回)

# はじめに

かくかくしかじかで、Docker で Amazon Linux 2 ベースの LAMP 環境を構築する機会がありましたので、手順についてアウトプットします。
![スクリーンショット 2022-11-30 23.31.45.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/527226/930bcd24-38e9-316e-bebd-cef83aea5924.png)

全 8 回を予定しています。

[① 作成する環境の確認](https://qiita.com/ryamate/items/47183e1ffd4843ef18fa)
[② Apache の導入](https://qiita.com/ryamate/items/e5ca19aece61717b6a01)
**③ PHP 8.1 系のインストール**
[④ Composer のインストール](https://qiita.com/ryamate/items/a8bbd003c6c2abceedc9)
[⑤ timezone, locale の設定](https://qiita.com/ryamate/items/d148bcdbdb27c5b80ad8)
[⑥ docker-compose.yml の作成（MySQL の導入）](https://qiita.com/ryamate/items/ac52b152757141f443e3)
[⑦ Laravel 9 系のインストール](https://qiita.com/ryamate/items/79875e22906cfb51af67)
[⑧ Apache の設定ファイルの追加](https://qiita.com/ryamate/items/18747f5241df487ea497)

今回は、 **③ PHP 8.1 系のインストール** についてです。

## 環境

以下の Docker 環境を構築します。

- Amazon Linux 2
- Apache 2.4
- MySQL 8.0.28
- PHP 8.1.x
- Laravel 9.x

## 目次

[1. Docker コンテナでのシェル実行の準備](#1-docker-コンテナでのシェル実行の準備)
[2. PHP 8.1 系のインストール](#2--php-81-系のインストール)
　[2-1. vim のインストール](#2-1-vim-のインストール)
　[2-2. EPEL のインストール](#2-2-epel-のインストール)
　[2-3. Remi's RPM repository のインストール](#2-3-remis-rpm-repository-のインストール)
　[2-4. PHP 8.1 系のインストール](#2-4-php-81-系のインストール)
　[2-5. インストール完了の確認](#2-5-インストール完了の確認)
[3. Docker イメージとコンテナの再作成](#3-docker-イメージとコンテナの再作成)

# 1. Docker コンテナでのシェル実行の準備

Docker コンテナでのシェルの実行するため、コンテナの中に入ります。

## 1-1. Dockerfile の確認

前回（② Apache の導入）までの Dockerfile を確認します。

```docker:Dockerfile
FROM amazonlinux:2

RUN yum update -y \
  && yum install -y httpd

CMD [ "apachectl", "-D", "FOREGROUND" ]
```

## 1-2. Docker コンテナでのシェルの実行

Docker コンテナの中に入ります。

```bash
docker container exec -it advent-calendar /bin/bash
```

以降、シェルを Docker コンテナで実行します。

# 2.  PHP 8.1 系のインストール

Amazon Linux 2 に PHP 8.1.x をインストールします。

## 2-1. vim のインストール

まずは、 yum で **vim** をインストールします。

```bash
yum install -y vim
```

<details><summary>実行時ログ</summary>

```bash
bash-4.2# yum install -y vim
Loaded plugins: ovl, priorities
amzn2-core                                                                                                                                                                                                             | 3.7 kB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package vim-enhanced.aarch64 2:9.0.475-1.amzn2.0.1 will be installed
--> Processing Dependency: vim-common = 2:9.0.475-1.amzn2.0.1 for package: 2:vim-enhanced-9.0.475-1.amzn2.0.1.aarch64
--> Processing Dependency: which for package: 2:vim-enhanced-9.0.475-1.amzn2.0.1.aarch64
--> Processing Dependency: libgpm.so.2()(64bit) for package: 2:vim-enhanced-9.0.475-1.amzn2.0.1.aarch64
--> Running transaction check
---> Package gpm-libs.aarch64 0:1.20.7-15.amzn2.0.2 will be installed
---> Package vim-common.aarch64 2:9.0.475-1.amzn2.0.1 will be installed
--> Processing Dependency: vim-filesystem for package: 2:vim-common-9.0.475-1.amzn2.0.1.aarch64
---> Package which.aarch64 0:2.20-7.amzn2.0.2 will be installed
--> Running transaction check
---> Package vim-filesystem.noarch 2:9.0.475-1.amzn2.0.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================================================================================================
 Package                                                   Arch                                               Version                                                             Repository                                             Size
==============================================================================================================================================================================================================================================
Installing:
 vim-enhanced                                              aarch64                                            2:9.0.475-1.amzn2.0.1                                               amzn2-core                                            1.7 M
Installing for dependencies:
 gpm-libs                                                  aarch64                                            1.20.7-15.amzn2.0.2                                                 amzn2-core                                             34 k
 vim-common                                                aarch64                                            2:9.0.475-1.amzn2.0.1                                               amzn2-core                                            7.8 M
 vim-filesystem                                            noarch                                             2:9.0.475-1.amzn2.0.1                                               amzn2-core                                             72 k
 which                                                     aarch64                                            2.20-7.amzn2.0.2                                                    amzn2-core                                             41 k

Transaction Summary
==============================================================================================================================================================================================================================================
Install  1 Package (+4 Dependent packages)

Total download size: 9.6 M
Installed size: 38 M
Downloading packages:
(1/5): vim-common-9.0.475-1.amzn2.0.1.aarch64.rpm                                                                                                                                                                      | 7.8 MB  00:00:01
(2/5): vim-enhanced-9.0.475-1.amzn2.0.1.aarch64.rpm                                                                                                                                                                    | 1.7 MB  00:00:00
(3/5): gpm-libs-1.20.7-15.amzn2.0.2.aarch64.rpm                                                                                                                                                                        |  34 kB  00:00:01
(4/5): vim-filesystem-9.0.475-1.amzn2.0.1.noarch.rpm                                                                                                                                                                   |  72 kB  00:00:00
(5/5): which-2.20-7.amzn2.0.2.aarch64.rpm                                                                                                                                                                              |  41 kB  00:00:00
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                         5.9 MB/s | 9.6 MB  00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : gpm-libs-1.20.7-15.amzn2.0.2.aarch64                                                                                                                                                                                       1/5
  Installing : which-2.20-7.amzn2.0.2.aarch64                                                                                                                                                                                             2/5
  Installing : 2:vim-filesystem-9.0.475-1.amzn2.0.1.noarch                                                                                                                                                                                3/5
  Installing : 2:vim-common-9.0.475-1.amzn2.0.1.aarch64                                                                                                                                                                                   4/5
  Installing : 2:vim-enhanced-9.0.475-1.amzn2.0.1.aarch64                                                                                                                                                                                 5/5
  Verifying  : 2:vim-filesystem-9.0.475-1.amzn2.0.1.noarch                                                                                                                                                                                1/5
  Verifying  : which-2.20-7.amzn2.0.2.aarch64                                                                                                                                                                                             2/5
  Verifying  : 2:vim-common-9.0.475-1.amzn2.0.1.aarch64                                                                                                                                                                                   3/5
  Verifying  : 2:vim-enhanced-9.0.475-1.amzn2.0.1.aarch64                                                                                                                                                                                 4/5
  Verifying  : gpm-libs-1.20.7-15.amzn2.0.2.aarch64                                                                                                                                                                                       5/5

Installed:
  vim-enhanced.aarch64 2:9.0.475-1.amzn2.0.1

Dependency Installed:
  gpm-libs.aarch64 0:1.20.7-15.amzn2.0.2                     vim-common.aarch64 2:9.0.475-1.amzn2.0.1                     vim-filesystem.noarch 2:9.0.475-1.amzn2.0.1                     which.aarch64 0:2.20-7.amzn2.0.2

Complete!
```

</details>

## 2-2. EPEL のインストール

**Extras Library** で **EPEL** をインストールします。

```bash
amazon-linux-extras install -y epel
```

<details><summary>実行時ログ</summary>

```bash
bash-4.2# amazon-linux-extras install -y epel
Installing epel-release
Loaded plugins: ovl, priorities
Cleaning repos: amzn2-core amzn2extra-epel
6 metadata files removed
2 sqlite files removed
0 metadata files removed
Loaded plugins: ovl, priorities
amzn2-core                                                                                                                                                                               | 3.7 kB  00:00:00
amzn2extra-epel                                                                                                                                                                          | 3.0 kB  00:00:00
(1/5): amzn2-core/2/x86_64/group_gz                                                                                                                                                      | 2.5 kB  00:00:00
(2/5): amzn2extra-epel/2/x86_64/updateinfo                                                                                                                                               |   76 B  00:00:00
(3/5): amzn2extra-epel/2/x86_64/primary_db                                                                                                                                               | 1.8 kB  00:00:00
(4/5): amzn2-core/2/x86_64/updateinfo                                                                                                                                                    | 525 kB  00:00:00
(5/5): amzn2-core/2/x86_64/primary_db                                                                                                                                                    |  66 MB  00:00:18
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================================================================================
 Package                                              Arch                                           Version                                      Repository                                               Size
================================================================================================================================================================================================================
Installing:
 epel-release                                         noarch                                         7-11                                         amzn2extra-epel                                          15 k

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

Total download size: 15 k
Installed size: 24 k
Downloading packages:
epel-release-7-11.noarch.rpm                                                                                                                                                             |  15 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : epel-release-7-11.noarch                                                                                                                                                                     1/1
  Verifying  : epel-release-7-11.noarch                                                                                                                                                                     1/1

Installed:
  epel-release.noarch 0:7-11

Complete!
  0  ansible2                 available    \
        [ =2.4.2  =2.4.6  =2.8  =stable ]
  2  httpd_modules            available    [ =1.0  =stable ]
  3  memcached1.5             available    \
        [ =1.5.1  =1.5.16  =1.5.17 ]
  6  postgresql10             available    [ =10  =stable ]
  9  R3.4                     available    [ =3.4.3  =stable ]
 10  rust1                    available    \
        [ =1.22.1  =1.26.0  =1.26.1  =1.27.2  =1.31.0  =1.38.0
          =stable ]
 18  libreoffice              available    \
        [ =5.0.6.2_15  =5.3.6.1  =stable ]
 19  gimp                     available    [ =2.8.22 ]
 20  docker                   available    \
        [ =17.12.1  =18.03.1  =18.06.1  =18.09.9  =stable ]
 21  mate-desktop1.x          available    \
        [ =1.19.0  =1.20.0  =stable ]
 22  GraphicsMagick1.3        available    \
        [ =1.3.29  =1.3.32  =1.3.34  =stable ]
 23  tomcat8.5                available    \
        [ =8.5.31  =8.5.32  =8.5.38  =8.5.40  =8.5.42  =8.5.50
          =stable ]
 24  epel=latest              enabled      [ =7.11  =stable ]
 25  testing                  available    [ =1.0  =stable ]
 26  ecs                      available    [ =stable ]
 27  corretto8                available    \
        [ =1.8.0_192  =1.8.0_202  =1.8.0_212  =1.8.0_222  =1.8.0_232
          =1.8.0_242  =stable ]
 28  firecracker              available    [ =0.11  =stable ]
 29  golang1.11               available    \
        [ =1.11.3  =1.11.11  =1.11.13  =stable ]
 30  squid4                   available    [ =4  =stable ]
 32  lustre2.10               available    \
        [ =2.10.5  =2.10.8  =stable ]
 33  java-openjdk11           available    [ =11  =stable ]
 34  lynis                    available    [ =stable ]
 36  BCC                      available    [ =0.x  =stable ]
 37  mono                     available    [ =5.x  =stable ]
 38  nginx1                   available    [ =stable ]
 39  ruby2.6                  available    [ =2.6  =stable ]
 40  mock                     available    [ =stable ]
 41  postgresql11             available    [ =11  =stable ]
 42  php7.4                   available    [ =stable ]
 43  livepatch                available    [ =stable ]
 44  python3.8                available    [ =stable ]
 45  haproxy2                 available    [ =stable ]
 46  collectd                 available    [ =stable ]
 47  aws-nitro-enclaves-cli   available    [ =stable ]
 48  R4                       available    [ =stable ]
 49  kernel-5.4               available    [ =stable ]
 50  selinux-ng               available    [ =stable ]
 51  php8.0                   available    [ =stable ]
 52  tomcat9                  available    [ =stable ]
 53  unbound1.13              available    [ =stable ]
 54  mariadb10.5              available    [ =stable ]
 55  kernel-5.10              available    [ =stable ]
 56  redis6                   available    [ =stable ]
 57  ruby3.0                  available    [ =stable ]
 58  postgresql12             available    [ =stable ]
 59  postgresql13             available    [ =stable ]
 60  mock2                    available    [ =stable ]
 61  dnsmasq2.85              available    [ =stable ]
 62  kernel-5.15              available    [ =stable ]
 63  postgresql14             available    [ =stable ]
 64  firefox                  available    [ =stable ]
 65  lustre                   available    [ =stable ]
```

</details>

### Extras Library（amazon-linux-extras） とは

> Amazon Linux 2には Extras Library と呼ばれるパッケージ群が存在し、Python、Golang、MariaDB、Ansible などの特定のパッケージをより新しいバージョンで利用することが出来ます。 Extra Packages for Enterprise Linux (EPEL) のような位置づけで、通常はディストリビューション標準のパッケージを利用する一方で、特定のパケージではより新しいバージョンを試せます。
> 
> 
> この特別なパッケージは AWS がキュレートし、**`amazon-linux-extras`** コマンド経由で管理します。
> 

https://dev.classmethod.jp/articles/how-to-work-with-amazon-linux2-amazon-linux-extras/

### EPEL とは

> EPEL が開始されたのは、多くの Fedora の貢献者が、Red Hat Enterprise Linux (RHEL) およびその互換性のある派生物で維持している Fedora パッケージを使用したかったためです。
> 

> Fedora で開発、テスト、改善された高品質のパッケージを、RHEL や、CentOS や Scientific Linux などの互換性のある派生製品で利用できるようにします。
> 

https://docs.fedoraproject.org/en-US/epel/epel-about/

## 2-3. Remi's RPM repository のインストール

yum で **Remi's RPM repository** をインストールします。

```bash
yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm
```

<details><summary>実行時ログ</summary>

```bash
bash-4.2# yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm
Loaded plugins: ovl, priorities
remi-release-7.rpm                                                                                                                                                                       |  23 kB  00:00:00
Examining /var/tmp/yum-root-8UyhgZ/remi-release-7.rpm: remi-release-7.9-4.el7.remi.noarch
Marking /var/tmp/yum-root-8UyhgZ/remi-release-7.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package remi-release.noarch 0:7.9-4.el7.remi will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================================================================================
 Package                                           Arch                                        Version                                               Repository                                            Size
================================================================================================================================================================================================================
Installing:
 remi-release                                      noarch                                      7.9-4.el7.remi                                        /remi-release-7                                       35 k

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

Total size: 35 k
Installed size: 35 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : remi-release-7.9-4.el7.remi.noarch                                                                                                                                                           1/1
  Verifying  : remi-release-7.9-4.el7.remi.noarch                                                                                                                                                           1/1

Installed:
  remi-release.noarch 0:7.9-4.el7.remi

Complete!
```

</details>

### Remi's RPM repository とは

https://rpms.remirepo.net/

> remiリポジトリは、サードパーティリポジトリと呼ばれる、CentOSが標準で用意している以外のサードパーティが提供しているリポジトリの一種です。
> 

https://www.geekfeed.co.jp/geekblog/centos-remi-epel-php#remi

※ 「サードパーティー」は、第三者団体のこと

:::note alert
追記 2023/01/17 ： **M1 Mac の場合、 Docker コンテナが起動しない**
- AmazonLinux2、PHP8.1だと remi リポジトリが必要
→ remi7 は M1 対応していない
→ 現状対処できない様子
:::

https://engineer.blog.lancers.jp/php/php81-docker/

## 2-4. PHP 8.1 系のインストール

PHP 8.1.x をインストールします。

```bash
yum clean metadata && yum -y install php81 php81-php php81-php-mbstring php81-php-pdo php81-php-gd php81-php-mysqlnd php81-php-xml php81-php-fpm
```

<details><summary>実行時ログ</summary>

```bash
bash-4.2# yum clean metadata && yum -y install php81 php81-php-mbstring php81-php-pdo php81-php-xml php81-php-fpm php81-php-mysqlnd php81-php-gd
Loaded plugins: ovl, priorities
Cleaning repos: amzn2-core amzn2extra-epel epel remi-safe
9 metadata files removed
4 sqlite files removed
0 metadata files removed
Loaded plugins: ovl, priorities
amzn2-core                                                                                                                                                                               | 3.7 kB  00:00:00
amzn2extra-epel                                                                                                                                                                          | 3.0 kB  00:00:00
epel/x86_64/metalink                                                                                                                                                                     | 6.4 kB  00:00:00
epel                                                                                                                                                                                     | 4.7 kB  00:00:00
remi-safe                                                                                                                                                                                | 3.0 kB  00:00:00
(1/9): amzn2-core/2/x86_64/group_gz                                                                                                                                                      | 2.5 kB  00:00:00
(2/9): amzn2-core/2/x86_64/updateinfo                                                                                                                                                    | 525 kB  00:00:00
(3/9): amzn2extra-epel/2/x86_64/updateinfo                                                                                                                                               |   76 B  00:00:00
(4/9): amzn2extra-epel/2/x86_64/primary_db                                                                                                                                               | 1.8 kB  00:00:00
(5/9): epel/x86_64/group_gz                                                                                                                                                              |  98 kB  00:00:01
(6/9): epel/x86_64/updateinfo                                                                                                                                                            | 1.0 MB  00:00:03
(7/9): epel/x86_64/primary_db                                                                                                                                                            | 7.0 MB  00:00:05
(8/9): remi-safe/primary_db                                                                                                                                                              | 2.3 MB  00:00:07
(9/9): amzn2-core/2/x86_64/primary_db                                                                                                                                                    |  66 MB  00:00:32
236 packages excluded due to repository priority protections
Resolving Dependencies
--> Running transaction check
---> Package php81.x86_64 0:8.1-1.el7.remi will be installed
--> Processing Dependency: php81-runtime(x86-64) = 8.1-1.el7.remi for package: php81-8.1-1.el7.remi.x86_64
--> Processing Dependency: php81-runtime for package: php81-8.1-1.el7.remi.x86_64
--> Processing Dependency: php81-php-common(x86-64) for package: php81-8.1-1.el7.remi.x86_64
--> Processing Dependency: php81-php-cli(x86-64) for package: php81-8.1-1.el7.remi.x86_64
---> Package php81-php-fpm.x86_64 0:8.1.12-1.el7.remi will be installed
--> Processing Dependency: systemd-sysv for package: php81-php-fpm-8.1.12-1.el7.remi.x86_64
---> Package php81-php-gd.x86_64 0:8.1.12-1.el7.remi will be installed
--> Processing Dependency: libgd.so.103()(64bit) for package: php81-php-gd-8.1.12-1.el7.remi.x86_64
---> Package php81-php-mbstring.x86_64 0:8.1.12-1.el7.remi will be installed
--> Processing Dependency: libonig.so.105()(64bit) for package: php81-php-mbstring-8.1.12-1.el7.remi.x86_64
---> Package php81-php-mysqlnd.x86_64 0:8.1.12-1.el7.remi will be installed
---> Package php81-php-pdo.x86_64 0:8.1.12-1.el7.remi will be installed
---> Package php81-php-xml.x86_64 0:8.1.12-1.el7.remi will be installed
--> Processing Dependency: libxslt.so.1(LIBXML2_1.0.11)(64bit) for package: php81-php-xml-8.1.12-1.el7.remi.x86_64
--> Processing Dependency: libxslt.so.1(LIBXML2_1.0.13)(64bit) for package: php81-php-xml-8.1.12-1.el7.remi.x86_64
--> Processing Dependency: libxslt.so.1(LIBXML2_1.0.18)(64bit) for package: php81-php-xml-8.1.12-1.el7.remi.x86_64
--> Processing Dependency: libxslt.so.1(LIBXML2_1.0.22)(64bit) for package: php81-php-xml-8.1.12-1.el7.remi.x86_64
--> Processing Dependency: libxslt.so.1(LIBXML2_1.0.24)(64bit) for package: php81-php-xml-8.1.12-1.el7.remi.x86_64
--> Processing Dependency: libexslt.so.0()(64bit) for package: php81-php-xml-8.1.12-1.el7.remi.x86_64
--> Processing Dependency: libxslt.so.1()(64bit) for package: php81-php-xml-8.1.12-1.el7.remi.x86_64
--> Running transaction check
---> Package gd3php.x86_64 0:2.3.3-7.el7.remi will be installed
--> Processing Dependency: libjpeg.so.62(LIBJPEG_6.2)(64bit) for package: gd3php-2.3.3-7.el7.remi.x86_64
--> Processing Dependency: libpng15.so.15(PNG15_0)(64bit) for package: gd3php-2.3.3-7.el7.remi.x86_64
--> Processing Dependency: libtiff.so.5(LIBTIFF_4.0)(64bit) for package: gd3php-2.3.3-7.el7.remi.x86_64
--> Processing Dependency: libX11.so.6()(64bit) for package: gd3php-2.3.3-7.el7.remi.x86_64
--> Processing Dependency: libXpm.so.4()(64bit) for package: gd3php-2.3.3-7.el7.remi.x86_64
--> Processing Dependency: libfontconfig.so.1()(64bit) for package: gd3php-2.3.3-7.el7.remi.x86_64
--> Processing Dependency: libfreetype.so.6()(64bit) for package: gd3php-2.3.3-7.el7.remi.x86_64
--> Processing Dependency: libjpeg.so.62()(64bit) for package: gd3php-2.3.3-7.el7.remi.x86_64
--> Processing Dependency: libpng15.so.15()(64bit) for package: gd3php-2.3.3-7.el7.remi.x86_64
--> Processing Dependency: libraqm.so.0()(64bit) for package: gd3php-2.3.3-7.el7.remi.x86_64
--> Processing Dependency: libtiff.so.5()(64bit) for package: gd3php-2.3.3-7.el7.remi.x86_64
--> Processing Dependency: libwebp.so.7()(64bit) for package: gd3php-2.3.3-7.el7.remi.x86_64
---> Package libxslt.x86_64 0:1.1.28-6.amzn2 will be installed
---> Package oniguruma5php.x86_64 0:6.9.8-1.el7.remi will be installed
---> Package php81-php-cli.x86_64 0:8.1.12-1.el7.remi will be installed
--> Processing Dependency: libedit.so.0()(64bit) for package: php81-php-cli-8.1.12-1.el7.remi.x86_64
--> Processing Dependency: libncurses.so.5()(64bit) for package: php81-php-cli-8.1.12-1.el7.remi.x86_64
--> Processing Dependency: libtinfo.so.5()(64bit) for package: php81-php-cli-8.1.12-1.el7.remi.x86_64
---> Package php81-php-common.x86_64 0:8.1.12-1.el7.remi will be installed
---> Package php81-runtime.x86_64 0:8.1-1.el7.remi will be installed
--> Processing Dependency: /usr/sbin/selinuxenabled for package: php81-runtime-8.1-1.el7.remi.x86_64
--> Processing Dependency: /usr/sbin/semanage for package: php81-runtime-8.1-1.el7.remi.x86_64
--> Processing Dependency: environment-modules for package: php81-runtime-8.1-1.el7.remi.x86_64
--> Processing Dependency: scl-utils for package: php81-runtime-8.1-1.el7.remi.x86_64
---> Package systemd-sysv.x86_64 0:219-78.amzn2.0.20 will be installed
--> Running transaction check
---> Package environment-modules.x86_64 0:3.2.10-10.amzn2.0.2 will be installed
--> Processing Dependency: procps for package: environment-modules-3.2.10-10.amzn2.0.2.x86_64
--> Processing Dependency: libtcl8.5.so()(64bit) for package: environment-modules-3.2.10-10.amzn2.0.2.x86_64
---> Package fontconfig.x86_64 0:2.13.0-4.3.amzn2 will be installed
--> Processing Dependency: fontpackages-filesystem for package: fontconfig-2.13.0-4.3.amzn2.x86_64
--> Processing Dependency: dejavu-sans-fonts for package: fontconfig-2.13.0-4.3.amzn2.x86_64
---> Package freetype.x86_64 0:2.8-14.amzn2.1 will be installed
---> Package libX11.x86_64 0:1.6.7-3.amzn2.0.2 will be installed
--> Processing Dependency: libX11-common >= 1.6.7-3.amzn2.0.2 for package: libX11-1.6.7-3.amzn2.0.2.x86_64
--> Processing Dependency: libxcb.so.1()(64bit) for package: libX11-1.6.7-3.amzn2.0.2.x86_64
---> Package libXpm.x86_64 0:3.5.12-1.amzn2.0.2 will be installed
---> Package libedit.x86_64 0:3.0-12.20121213cvs.amzn2.0.2 will be installed
---> Package libjpeg-turbo.x86_64 0:2.0.90-2.amzn2.0.1 will be installed
---> Package libpng.x86_64 2:1.5.13-8.amzn2 will be installed
---> Package libraqm.x86_64 0:0.7.0-4.el7 will be installed
--> Processing Dependency: libfribidi.so.0()(64bit) for package: libraqm-0.7.0-4.el7.x86_64
--> Processing Dependency: libharfbuzz.so.0()(64bit) for package: libraqm-0.7.0-4.el7.x86_64
---> Package libselinux-utils.x86_64 0:2.5-12.amzn2.0.2 will be installed
---> Package libtiff.x86_64 0:4.0.3-35.amzn2.0.3 will be installed
--> Processing Dependency: libjbig.so.2.0()(64bit) for package: libtiff-4.0.3-35.amzn2.0.3.x86_64
---> Package libwebp7.x86_64 0:1.0.3-1.el7.remi will be installed
---> Package ncurses-compat-libs.x86_64 0:6.0-8.20170212.amzn2.1.3 will be installed
---> Package policycoreutils-python.x86_64 0:2.5-22.amzn2 will be installed
--> Processing Dependency: policycoreutils = 2.5-22.amzn2 for package: policycoreutils-python-2.5-22.amzn2.x86_64
--> Processing Dependency: setools-libs >= 3.3.8-2 for package: policycoreutils-python-2.5-22.amzn2.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-9 for package: policycoreutils-python-2.5-22.amzn2.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-22.amzn2.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-22.amzn2.x86_64
--> Processing Dependency: libselinux-python for package: policycoreutils-python-2.5-22.amzn2.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-22.amzn2.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-22.amzn2.x86_64
--> Processing Dependency: libcgroup for package: policycoreutils-python-2.5-22.amzn2.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-22.amzn2.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-22.amzn2.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-22.amzn2.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-22.amzn2.x86_64
---> Package scl-utils.x86_64 0:20130529-18.amzn2.0.1 will be installed
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.8.1-3.amzn2.1 will be installed
---> Package checkpolicy.x86_64 0:2.5-6.amzn2 will be installed
---> Package dejavu-sans-fonts.noarch 0:2.33-6.amzn2 will be installed
--> Processing Dependency: dejavu-fonts-common = 2.33-6.amzn2 for package: dejavu-sans-fonts-2.33-6.amzn2.noarch
---> Package fontpackages-filesystem.noarch 0:1.44-8.amzn2 will be installed
---> Package fribidi.x86_64 0:1.0.2-1.amzn2.1 will be installed
---> Package harfbuzz.x86_64 0:1.7.5-2.amzn2 will be installed
--> Processing Dependency: libgraphite2.so.3()(64bit) for package: harfbuzz-1.7.5-2.amzn2.x86_64
---> Package jbigkit-libs.x86_64 0:2.0-11.amzn2.0.2 will be installed
---> Package libX11-common.noarch 0:1.6.7-3.amzn2.0.2 will be installed
---> Package libcgroup.x86_64 0:0.41-21.amzn2 will be installed
---> Package libselinux-python.x86_64 0:2.5-12.amzn2.0.2 will be installed
---> Package libsemanage-python.x86_64 0:2.5-11.amzn2 will be installed
---> Package libxcb.x86_64 0:1.12-1.amzn2.0.2 will be installed
--> Processing Dependency: libXau.so.6()(64bit) for package: libxcb-1.12-1.amzn2.0.2.x86_64
---> Package policycoreutils.x86_64 0:2.5-22.amzn2 will be installed
---> Package procps-ng.x86_64 0:3.3.10-26.amzn2 will be installed
---> Package python-IPy.noarch 0:0.75-6.amzn2.0.1 will be installed
---> Package setools-libs.x86_64 0:3.3.8-2.amzn2.0.2 will be installed
---> Package tcl.x86_64 1:8.5.13-8.amzn2.0.2 will be installed
--> Running transaction check
---> Package dejavu-fonts-common.noarch 0:2.33-6.amzn2 will be installed
---> Package graphite2.x86_64 0:1.3.10-1.amzn2.0.2 will be installed
---> Package libXau.x86_64 0:1.0.8-2.1.amzn2.0.2 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================================================================================
 Package                                                 Arch                                   Version                                                        Repository                                  Size
================================================================================================================================================================================================================
Installing:
 php81                                                   x86_64                                 8.1-1.el7.remi                                                 remi-safe                                  2.9 k
 php81-php-fpm                                           x86_64                                 8.1.12-1.el7.remi                                              remi-safe                                  2.0 M
 php81-php-gd                                            x86_64                                 8.1.12-1.el7.remi                                              remi-safe                                   94 k
 php81-php-mbstring                                      x86_64                                 8.1.12-1.el7.remi                                              remi-safe                                  486 k
 php81-php-mysqlnd                                       x86_64                                 8.1.12-1.el7.remi                                              remi-safe                                  193 k
 php81-php-pdo                                           x86_64                                 8.1.12-1.el7.remi                                              remi-safe                                  134 k
 php81-php-xml                                           x86_64                                 8.1.12-1.el7.remi                                              remi-safe                                  187 k
Installing for dependencies:
 audit-libs-python                                       x86_64                                 2.8.1-3.amzn2.1                                                amzn2-core                                  79 k
 checkpolicy                                             x86_64                                 2.5-6.amzn2                                                    amzn2-core                                 294 k
 dejavu-fonts-common                                     noarch                                 2.33-6.amzn2                                                   amzn2-core                                  64 k
 dejavu-sans-fonts                                       noarch                                 2.33-6.amzn2                                                   amzn2-core                                 1.4 M
 environment-modules                                     x86_64                                 3.2.10-10.amzn2.0.2                                            amzn2-core                                 107 k
 fontconfig                                              x86_64                                 2.13.0-4.3.amzn2                                               amzn2-core                                 253 k
 fontpackages-filesystem                                 noarch                                 1.44-8.amzn2                                                   amzn2-core                                  10 k
 freetype                                                x86_64                                 2.8-14.amzn2.1                                                 amzn2-core                                 373 k
 fribidi                                                 x86_64                                 1.0.2-1.amzn2.1                                                amzn2-core                                  79 k
 gd3php                                                  x86_64                                 2.3.3-7.el7.remi                                               remi-safe                                  138 k
 graphite2                                               x86_64                                 1.3.10-1.amzn2.0.2                                             amzn2-core                                 115 k
 harfbuzz                                                x86_64                                 1.7.5-2.amzn2                                                  amzn2-core                                 279 k
 jbigkit-libs                                            x86_64                                 2.0-11.amzn2.0.2                                               amzn2-core                                  47 k
 libX11                                                  x86_64                                 1.6.7-3.amzn2.0.2                                              amzn2-core                                 606 k
 libX11-common                                           noarch                                 1.6.7-3.amzn2.0.2                                              amzn2-core                                 165 k
 libXau                                                  x86_64                                 1.0.8-2.1.amzn2.0.2                                            amzn2-core                                  29 k
 libXpm                                                  x86_64                                 3.5.12-1.amzn2.0.2                                             amzn2-core                                  57 k
 libcgroup                                               x86_64                                 0.41-21.amzn2                                                  amzn2-core                                  66 k
 libedit                                                 x86_64                                 3.0-12.20121213cvs.amzn2.0.2                                   amzn2-core                                  93 k
 libjpeg-turbo                                           x86_64                                 2.0.90-2.amzn2.0.1                                             amzn2-core                                 170 k
 libpng                                                  x86_64                                 2:1.5.13-8.amzn2                                               amzn2-core                                 212 k
 libraqm                                                 x86_64                                 0.7.0-4.el7                                                    epel                                        15 k
 libselinux-python                                       x86_64                                 2.5-12.amzn2.0.2                                               amzn2-core                                 237 k
 libselinux-utils                                        x86_64                                 2.5-12.amzn2.0.2                                               amzn2-core                                 151 k
 libsemanage-python                                      x86_64                                 2.5-11.amzn2                                                   amzn2-core                                 115 k
 libtiff                                                 x86_64                                 4.0.3-35.amzn2.0.3                                             amzn2-core                                 174 k
 libwebp7                                                x86_64                                 1.0.3-1.el7.remi                                               remi-safe                                  266 k
 libxcb                                                  x86_64                                 1.12-1.amzn2.0.2                                               amzn2-core                                 216 k
 libxslt                                                 x86_64                                 1.1.28-6.amzn2                                                 amzn2-core                                 240 k
 ncurses-compat-libs                                     x86_64                                 6.0-8.20170212.amzn2.1.3                                       amzn2-core                                 308 k
 oniguruma5php                                           x86_64                                 6.9.8-1.el7.remi                                               remi-safe                                  207 k
 php81-php-cli                                           x86_64                                 8.1.12-1.el7.remi                                              remi-safe                                  3.9 M
 php81-php-common                                        x86_64                                 8.1.12-1.el7.remi                                              remi-safe                                  718 k
 php81-runtime                                           x86_64                                 8.1-1.el7.remi                                                 remi-safe                                  1.1 M
 policycoreutils                                         x86_64                                 2.5-22.amzn2                                                   amzn2-core                                 867 k
 policycoreutils-python                                  x86_64                                 2.5-22.amzn2                                                   amzn2-core                                 454 k
 procps-ng                                               x86_64                                 3.3.10-26.amzn2                                                amzn2-core                                 292 k
 python-IPy                                              noarch                                 0.75-6.amzn2.0.1                                               amzn2-core                                  32 k
 scl-utils                                               x86_64                                 20130529-18.amzn2.0.1                                          amzn2-core                                  24 k
 setools-libs                                            x86_64                                 3.3.8-2.amzn2.0.2                                              amzn2-core                                 618 k
 systemd-sysv                                            x86_64                                 219-78.amzn2.0.20                                              amzn2-core                                  98 k
 tcl                                                     x86_64                                 1:8.5.13-8.amzn2.0.2                                           amzn2-core                                 1.9 M

Transaction Summary
================================================================================================================================================================================================================
Install  7 Packages (+42 Dependent packages)

Total download size: 20 M
Installed size: 68 M
Downloading packages:
(1/49): audit-libs-python-2.8.1-3.amzn2.1.x86_64.rpm                                                                                                                                     |  79 kB  00:00:00
(2/49): checkpolicy-2.5-6.amzn2.x86_64.rpm                                                                                                                                               | 294 kB  00:00:00
(3/49): dejavu-fonts-common-2.33-6.amzn2.noarch.rpm                                                                                                                                      |  64 kB  00:00:00
(4/49): environment-modules-3.2.10-10.amzn2.0.2.x86_64.rpm                                                                                                                               | 107 kB  00:00:00
(5/49): fontconfig-2.13.0-4.3.amzn2.x86_64.rpm                                                                                                                                           | 253 kB  00:00:00
(6/49): fontpackages-filesystem-1.44-8.amzn2.noarch.rpm                                                                                                                                  |  10 kB  00:00:00
(7/49): freetype-2.8-14.amzn2.1.x86_64.rpm                                                                                                                                               | 373 kB  00:00:00
(8/49): dejavu-sans-fonts-2.33-6.amzn2.noarch.rpm                                                                                                                                        | 1.4 MB  00:00:01
(9/49): fribidi-1.0.2-1.amzn2.1.x86_64.rpm                                                                                                                                               |  79 kB  00:00:00
(10/49): graphite2-1.3.10-1.amzn2.0.2.x86_64.rpm                                                                                                                                         | 115 kB  00:00:00
(11/49): harfbuzz-1.7.5-2.amzn2.x86_64.rpm                                                                                                                                               | 279 kB  00:00:00
(12/49): libX11-1.6.7-3.amzn2.0.2.x86_64.rpm                                                                                                                                             | 606 kB  00:00:00
(13/49): libX11-common-1.6.7-3.amzn2.0.2.noarch.rpm                                                                                                                                      | 165 kB  00:00:00
(14/49): jbigkit-libs-2.0-11.amzn2.0.2.x86_64.rpm                                                                                                                                        |  47 kB  00:00:00
(15/49): libXau-1.0.8-2.1.amzn2.0.2.x86_64.rpm                                                                                                                                           |  29 kB  00:00:00
(16/49): libXpm-3.5.12-1.amzn2.0.2.x86_64.rpm                                                                                                                                            |  57 kB  00:00:00
(17/49): libcgroup-0.41-21.amzn2.x86_64.rpm                                                                                                                                              |  66 kB  00:00:00
(18/49): libedit-3.0-12.20121213cvs.amzn2.0.2.x86_64.rpm                                                                                                                                 |  93 kB  00:00:00
(19/49): libjpeg-turbo-2.0.90-2.amzn2.0.1.x86_64.rpm                                                                                                                                     | 170 kB  00:00:00
(20/49): libselinux-python-2.5-12.amzn2.0.2.x86_64.rpm                                                                                                                                   | 237 kB  00:00:00
(21/49): libpng-1.5.13-8.amzn2.x86_64.rpm                                                                                                                                                | 212 kB  00:00:00
(22/49): libselinux-utils-2.5-12.amzn2.0.2.x86_64.rpm                                                                                                                                    | 151 kB  00:00:00
warning: /var/cache/yum/x86_64/2/epel/packages/libraqm-0.7.0-4.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY                                         ] 1.1 MB/s | 4.8 MB  00:00:12 ETA
Public key for libraqm-0.7.0-4.el7.x86_64.rpm is not installed
(23/49): libraqm-0.7.0-4.el7.x86_64.rpm                                                                                                                                                  |  15 kB  00:00:00
(24/49): libtiff-4.0.3-35.amzn2.0.3.x86_64.rpm                                                                                                                                           | 174 kB  00:00:00
(25/49): libsemanage-python-2.5-11.amzn2.x86_64.rpm                                                                                                                                      | 115 kB  00:00:00
(26/49): libxcb-1.12-1.amzn2.0.2.x86_64.rpm                                                                                                                                              | 216 kB  00:00:00
(27/49): libxslt-1.1.28-6.amzn2.x86_64.rpm                                                                                                                                               | 240 kB  00:00:00
(28/49): ncurses-compat-libs-6.0-8.20170212.amzn2.1.3.x86_64.rpm                                                                                                                         | 308 kB  00:00:00
warning: /var/cache/yum/x86_64/2/remi-safe/packages/php81-8.1-1.el7.remi.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY                                     ] 1.2 MB/s | 5.9 MB  00:00:11 ETA
Public key for php81-8.1-1.el7.remi.x86_64.rpm is not installed
(29/49): php81-8.1-1.el7.remi.x86_64.rpm                                                                                                                                                 | 2.9 kB  00:00:00
(30/49): oniguruma5php-6.9.8-1.el7.remi.x86_64.rpm                                                                                                                                       | 207 kB  00:00:01
(31/49): gd3php-2.3.3-7.el7.remi.x86_64.rpm                                                                                                                                              | 138 kB  00:00:03
(32/49): php81-php-gd-8.1.12-1.el7.remi.x86_64.rpm                                                                                                                                       |  94 kB  00:00:00
(33/49): php81-php-mbstring-8.1.12-1.el7.remi.x86_64.rpm                                                                                                                                 | 486 kB  00:00:00
(34/49): php81-php-common-8.1.12-1.el7.remi.x86_64.rpm                                                                                                                                   | 718 kB  00:00:02
(35/49): php81-php-mysqlnd-8.1.12-1.el7.remi.x86_64.rpm                                                                                                                                  | 193 kB  00:00:00
(36/49): php81-php-fpm-8.1.12-1.el7.remi.x86_64.rpm                                                                                                                                      | 2.0 MB  00:00:02
(37/49): php81-php-pdo-8.1.12-1.el7.remi.x86_64.rpm                                                                                                                                      | 134 kB  00:00:00
(38/49): php81-php-xml-8.1.12-1.el7.remi.x86_64.rpm                                                                                                                                      | 187 kB  00:00:00
(39/49): php81-php-cli-8.1.12-1.el7.remi.x86_64.rpm                                                                                                                                      | 3.9 MB  00:00:05
(40/49): php81-runtime-8.1-1.el7.remi.x86_64.rpm                                                                                                                                         | 1.1 MB  00:00:01
(41/49): policycoreutils-2.5-22.amzn2.x86_64.rpm                                                                                                                                         | 867 kB  00:00:01
(42/49): procps-ng-3.3.10-26.amzn2.x86_64.rpm                                                                                                                                            | 292 kB  00:00:00
(43/49): policycoreutils-python-2.5-22.amzn2.x86_64.rpm                                                                                                                                  | 454 kB  00:00:01
(44/49): python-IPy-0.75-6.amzn2.0.1.noarch.rpm                                                                                                                                          |  32 kB  00:00:00
(45/49): scl-utils-20130529-18.amzn2.0.1.x86_64.rpm                                                                                                                                      |  24 kB  00:00:00
(46/49): systemd-sysv-219-78.amzn2.0.20.x86_64.rpm                                                                                                                                       |  98 kB  00:00:00
(47/49): setools-libs-3.3.8-2.amzn2.0.2.x86_64.rpm                                                                                                                                       | 618 kB  00:00:00
(48/49): tcl-8.5.13-8.amzn2.0.2.x86_64.rpm                                                                                                                                               | 1.9 MB  00:00:00
(49/49): libwebp7-1.0.3-1.el7.remi.x86_64.rpm                                                                                                                                            | 266 kB  00:00:08
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                           1.7 MB/s |  20 MB  00:00:11
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
Importing GPG key 0x00F97F56:
 Userid     : "Remi Collet <RPMS@FamilleCollet.com>"
 Fingerprint: 1ee0 4cce 88a4 ae4a a29a 5df5 004e 6f47 00f9 7f56
 Package    : remi-release-7.9-4.el7.remi.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
 Userid     : "Fedora EPEL (7) <epel@fedoraproject.org>"
 Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
 Package    : epel-release-7-11.noarch (@amzn2extra-epel)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libjpeg-turbo-2.0.90-2.amzn2.0.1.x86_64                                                                                                                                                     1/49
  Installing : 2:libpng-1.5.13-8.amzn2.x86_64                                                                                                                                                              2/49
  Installing : freetype-2.8-14.amzn2.1.x86_64                                                                                                                                                              3/49
  Installing : fontpackages-filesystem-1.44-8.amzn2.noarch                                                                                                                                                 4/49
  Installing : libselinux-utils-2.5-12.amzn2.0.2.x86_64                                                                                                                                                    5/49
  Installing : policycoreutils-2.5-22.amzn2.x86_64                                                                                                                                                         6/49
  Installing : dejavu-fonts-common-2.33-6.amzn2.noarch                                                                                                                                                     7/49
  Installing : dejavu-sans-fonts-2.33-6.amzn2.noarch                                                                                                                                                       8/49
  Installing : fontconfig-2.13.0-4.3.amzn2.x86_64                                                                                                                                                          9/49
  Installing : checkpolicy-2.5-6.amzn2.x86_64                                                                                                                                                             10/49
  Installing : graphite2-1.3.10-1.amzn2.0.2.x86_64                                                                                                                                                        11/49
  Installing : harfbuzz-1.7.5-2.amzn2.x86_64                                                                                                                                                              12/49
  Installing : libwebp7-1.0.3-1.el7.remi.x86_64                                                                                                                                                           13/49
  Installing : fribidi-1.0.2-1.amzn2.1.x86_64                                                                                                                                                             14/49
  Installing : libraqm-0.7.0-4.el7.x86_64                                                                                                                                                                 15/49
  Installing : libxslt-1.1.28-6.amzn2.x86_64                                                                                                                                                              16/49
  Installing : systemd-sysv-219-78.amzn2.0.20.x86_64                                                                                                                                                      17/49
  Installing : libXau-1.0.8-2.1.amzn2.0.2.x86_64                                                                                                                                                          18/49
  Installing : libxcb-1.12-1.amzn2.0.2.x86_64                                                                                                                                                             19/49
  Installing : libsemanage-python-2.5-11.amzn2.x86_64                                                                                                                                                     20/49
  Installing : ncurses-compat-libs-6.0-8.20170212.amzn2.1.3.x86_64                                                                                                                                        21/49
  Installing : scl-utils-20130529-18.amzn2.0.1.x86_64                                                                                                                                                     22/49
  Installing : procps-ng-3.3.10-26.amzn2.x86_64                                                                                                                                                           23/49
  Installing : libcgroup-0.41-21.amzn2.x86_64                                                                                                                                                             24/49
  Installing : oniguruma5php-6.9.8-1.el7.remi.x86_64                                                                                                                                                      25/49
  Installing : setools-libs-3.3.8-2.amzn2.0.2.x86_64                                                                                                                                                      26/49
  Installing : libX11-common-1.6.7-3.amzn2.0.2.noarch                                                                                                                                                     27/49
  Installing : libX11-1.6.7-3.amzn2.0.2.x86_64                                                                                                                                                            28/49
  Installing : libXpm-3.5.12-1.amzn2.0.2.x86_64                                                                                                                                                           29/49
  Installing : jbigkit-libs-2.0-11.amzn2.0.2.x86_64                                                                                                                                                       30/49
  Installing : libtiff-4.0.3-35.amzn2.0.3.x86_64                                                                                                                                                          31/49
  Installing : gd3php-2.3.3-7.el7.remi.x86_64                                                                                                                                                             32/49
  Installing : 1:tcl-8.5.13-8.amzn2.0.2.x86_64                                                                                                                                                            33/49
  Installing : environment-modules-3.2.10-10.amzn2.0.2.x86_64                                                                                                                                             34/49
  Installing : libedit-3.0-12.20121213cvs.amzn2.0.2.x86_64                                                                                                                                                35/49
  Installing : audit-libs-python-2.8.1-3.amzn2.1.x86_64                                                                                                                                                   36/49
  Installing : libselinux-python-2.5-12.amzn2.0.2.x86_64                                                                                                                                                  37/49
  Installing : python-IPy-0.75-6.amzn2.0.1.noarch                                                                                                                                                         38/49
  Installing : policycoreutils-python-2.5-22.amzn2.x86_64                                                                                                                                                 39/49
  Installing : php81-runtime-8.1-1.el7.remi.x86_64                                                                                                                                                        40/49
  Installing : php81-php-common-8.1.12-1.el7.remi.x86_64                                                                                                                                                  41/49
  Installing : php81-php-pdo-8.1.12-1.el7.remi.x86_64                                                                                                                                                     42/49
  Installing : php81-php-cli-8.1.12-1.el7.remi.x86_64                                                                                                                                                     43/49
  Installing : php81-8.1-1.el7.remi.x86_64                                                                                                                                                                44/49
  Installing : php81-php-mysqlnd-8.1.12-1.el7.remi.x86_64                                                                                                                                                 45/49
  Installing : php81-php-gd-8.1.12-1.el7.remi.x86_64                                                                                                                                                      46/49
  Installing : php81-php-fpm-8.1.12-1.el7.remi.x86_64                                                                                                                                                     47/49
  Installing : php81-php-mbstring-8.1.12-1.el7.remi.x86_64                                                                                                                                                48/49
  Installing : php81-php-xml-8.1.12-1.el7.remi.x86_64                                                                                                                                                     49/49
  Verifying  : python-IPy-0.75-6.amzn2.0.1.noarch                                                                                                                                                          1/49
  Verifying  : libselinux-python-2.5-12.amzn2.0.2.x86_64                                                                                                                                                   2/49
  Verifying  : freetype-2.8-14.amzn2.1.x86_64                                                                                                                                                              3/49
  Verifying  : php81-php-gd-8.1.12-1.el7.remi.x86_64                                                                                                                                                       4/49
  Verifying  : libselinux-utils-2.5-12.amzn2.0.2.x86_64                                                                                                                                                    5/49
  Verifying  : audit-libs-python-2.8.1-3.amzn2.1.x86_64                                                                                                                                                    6/49
  Verifying  : fontpackages-filesystem-1.44-8.amzn2.noarch                                                                                                                                                 7/49
  Verifying  : dejavu-fonts-common-2.33-6.amzn2.noarch                                                                                                                                                     8/49
  Verifying  : libxcb-1.12-1.amzn2.0.2.x86_64                                                                                                                                                              9/49
  Verifying  : libXpm-3.5.12-1.amzn2.0.2.x86_64                                                                                                                                                           10/49
  Verifying  : php81-php-fpm-8.1.12-1.el7.remi.x86_64                                                                                                                                                     11/49
  Verifying  : libedit-3.0-12.20121213cvs.amzn2.0.2.x86_64                                                                                                                                                12/49
  Verifying  : libX11-1.6.7-3.amzn2.0.2.x86_64                                                                                                                                                            13/49
  Verifying  : 1:tcl-8.5.13-8.amzn2.0.2.x86_64                                                                                                                                                            14/49
  Verifying  : policycoreutils-python-2.5-22.amzn2.x86_64                                                                                                                                                 15/49
  Verifying  : jbigkit-libs-2.0-11.amzn2.0.2.x86_64                                                                                                                                                       16/49
  Verifying  : libX11-common-1.6.7-3.amzn2.0.2.noarch                                                                                                                                                     17/49
  Verifying  : setools-libs-3.3.8-2.amzn2.0.2.x86_64                                                                                                                                                      18/49
  Verifying  : php81-php-mbstring-8.1.12-1.el7.remi.x86_64                                                                                                                                                19/49
  Verifying  : oniguruma5php-6.9.8-1.el7.remi.x86_64                                                                                                                                                      20/49
  Verifying  : libcgroup-0.41-21.amzn2.x86_64                                                                                                                                                             21/49
  Verifying  : policycoreutils-2.5-22.amzn2.x86_64                                                                                                                                                        22/49
  Verifying  : procps-ng-3.3.10-26.amzn2.x86_64                                                                                                                                                           23/49
  Verifying  : gd3php-2.3.3-7.el7.remi.x86_64                                                                                                                                                             24/49
  Verifying  : scl-utils-20130529-18.amzn2.0.1.x86_64                                                                                                                                                     25/49
  Verifying  : ncurses-compat-libs-6.0-8.20170212.amzn2.1.3.x86_64                                                                                                                                        26/49
  Verifying  : libsemanage-python-2.5-11.amzn2.x86_64                                                                                                                                                     27/49
  Verifying  : php81-php-xml-8.1.12-1.el7.remi.x86_64                                                                                                                                                     28/49
  Verifying  : dejavu-sans-fonts-2.33-6.amzn2.noarch                                                                                                                                                      29/49
  Verifying  : libXau-1.0.8-2.1.amzn2.0.2.x86_64                                                                                                                                                          30/49
  Verifying  : fontconfig-2.13.0-4.3.amzn2.x86_64                                                                                                                                                         31/49
  Verifying  : systemd-sysv-219-78.amzn2.0.20.x86_64                                                                                                                                                      32/49
  Verifying  : harfbuzz-1.7.5-2.amzn2.x86_64                                                                                                                                                              33/49
  Verifying  : libtiff-4.0.3-35.amzn2.0.3.x86_64                                                                                                                                                          34/49
  Verifying  : php81-php-mysqlnd-8.1.12-1.el7.remi.x86_64                                                                                                                                                 35/49
  Verifying  : 2:libpng-1.5.13-8.amzn2.x86_64                                                                                                                                                             36/49
  Verifying  : libraqm-0.7.0-4.el7.x86_64                                                                                                                                                                 37/49
  Verifying  : libjpeg-turbo-2.0.90-2.amzn2.0.1.x86_64                                                                                                                                                    38/49
  Verifying  : libxslt-1.1.28-6.amzn2.x86_64                                                                                                                                                              39/49
  Verifying  : php81-php-pdo-8.1.12-1.el7.remi.x86_64                                                                                                                                                     40/49
  Verifying  : fribidi-1.0.2-1.amzn2.1.x86_64                                                                                                                                                             41/49
  Verifying  : php81-php-common-8.1.12-1.el7.remi.x86_64                                                                                                                                                  42/49
  Verifying  : php81-runtime-8.1-1.el7.remi.x86_64                                                                                                                                                        43/49
  Verifying  : php81-php-cli-8.1.12-1.el7.remi.x86_64                                                                                                                                                     44/49
  Verifying  : environment-modules-3.2.10-10.amzn2.0.2.x86_64                                                                                                                                             45/49
  Verifying  : libwebp7-1.0.3-1.el7.remi.x86_64                                                                                                                                                           46/49
  Verifying  : php81-8.1-1.el7.remi.x86_64                                                                                                                                                                47/49
  Verifying  : graphite2-1.3.10-1.amzn2.0.2.x86_64                                                                                                                                                        48/49
  Verifying  : checkpolicy-2.5-6.amzn2.x86_64                                                                                                                                                             49/49

Installed:
  php81.x86_64 0:8.1-1.el7.remi                        php81-php-fpm.x86_64 0:8.1.12-1.el7.remi         php81-php-gd.x86_64 0:8.1.12-1.el7.remi          php81-php-mbstring.x86_64 0:8.1.12-1.el7.remi
  php81-php-mysqlnd.x86_64 0:8.1.12-1.el7.remi         php81-php-pdo.x86_64 0:8.1.12-1.el7.remi         php81-php-xml.x86_64 0:8.1.12-1.el7.remi

Dependency Installed:
  audit-libs-python.x86_64 0:2.8.1-3.amzn2.1          checkpolicy.x86_64 0:2.5-6.amzn2                         dejavu-fonts-common.noarch 0:2.33-6.amzn2        dejavu-sans-fonts.noarch 0:2.33-6.amzn2
  environment-modules.x86_64 0:3.2.10-10.amzn2.0.2    fontconfig.x86_64 0:2.13.0-4.3.amzn2                     fontpackages-filesystem.noarch 0:1.44-8.amzn2    freetype.x86_64 0:2.8-14.amzn2.1
  fribidi.x86_64 0:1.0.2-1.amzn2.1                    gd3php.x86_64 0:2.3.3-7.el7.remi                         graphite2.x86_64 0:1.3.10-1.amzn2.0.2            harfbuzz.x86_64 0:1.7.5-2.amzn2
  jbigkit-libs.x86_64 0:2.0-11.amzn2.0.2              libX11.x86_64 0:1.6.7-3.amzn2.0.2                        libX11-common.noarch 0:1.6.7-3.amzn2.0.2         libXau.x86_64 0:1.0.8-2.1.amzn2.0.2
  libXpm.x86_64 0:3.5.12-1.amzn2.0.2                  libcgroup.x86_64 0:0.41-21.amzn2                         libedit.x86_64 0:3.0-12.20121213cvs.amzn2.0.2    libjpeg-turbo.x86_64 0:2.0.90-2.amzn2.0.1
  libpng.x86_64 2:1.5.13-8.amzn2                      libraqm.x86_64 0:0.7.0-4.el7                             libselinux-python.x86_64 0:2.5-12.amzn2.0.2      libselinux-utils.x86_64 0:2.5-12.amzn2.0.2
  libsemanage-python.x86_64 0:2.5-11.amzn2            libtiff.x86_64 0:4.0.3-35.amzn2.0.3                      libwebp7.x86_64 0:1.0.3-1.el7.remi               libxcb.x86_64 0:1.12-1.amzn2.0.2
  libxslt.x86_64 0:1.1.28-6.amzn2                     ncurses-compat-libs.x86_64 0:6.0-8.20170212.amzn2.1.3    oniguruma5php.x86_64 0:6.9.8-1.el7.remi          php81-php-cli.x86_64 0:8.1.12-1.el7.remi
  php81-php-common.x86_64 0:8.1.12-1.el7.remi         php81-runtime.x86_64 0:8.1-1.el7.remi                    policycoreutils.x86_64 0:2.5-22.amzn2            policycoreutils-python.x86_64 0:2.5-22.amzn2
  procps-ng.x86_64 0:3.3.10-26.amzn2                  python-IPy.noarch 0:0.75-6.amzn2.0.1                     scl-utils.x86_64 0:20130529-18.amzn2.0.1         setools-libs.x86_64 0:3.3.8-2.amzn2.0.2
  systemd-sysv.x86_64 0:219-78.amzn2.0.20             tcl.x86_64 1:8.5.13-8.amzn2.0.2

Complete!
```

```bash
bash-4.2# php81 -v
PHP 8.1.12 (cli) (built: Oct 25 2022 17:30:00) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.12, Copyright (c) Zend Technologies
bash-4.2# php -v
bash: php: command not found
bash-4.2#
```

</details>

`php` コマンドで `php81` を利用できるようにします。（現状は、例えば `php -v` を実行してもバージョンが 8.1 にならない）

```bash
alternatives --install /usr/bin/php php /usr/bin/php81 1
```

> alternatives は、既存のファイルに新しい名前をつけて利用できるようにするシステムです。
> 
> 
> いくつかのファイルを同じ名前の元に登録すれば、切り替えられるようにすることができます。
> 

https://vinelinux.org/docs/vine6/cui-guide/update-alternatives.html

## 2-5. インストール完了の確認

PHP のバージョンを確認します。

```bash
php -v
```

<details><summary>実行時ログ</summary>

```bash
bash-4.2# alternatives --install /usr/bin/php php /usr/bin/php81 1
bash-4.2# php -v
PHP 8.1.12 (cli) (built: Oct 25 2022 17:30:00) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.12, Copyright (c) Zend Technologies
```

</details>

PHP の設定情報を出力するファイルを作成します。

```bash
vim /var/www/html/info.php
```

info.php を編集します。

```php:info.php
<?php
phpinfo();
```

http://localhost:8080/info.php にアクセスすると下記の画面が表示されます。

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/527226/20f81393-c322-c38b-9922-a0fcc08f01ab.png)

# 3. Docker イメージとコンテナの再作成

ここまで実行したコマンドを Dockerfile に記述して、 Docker イメージとコンテナを再作成します。

## 3-1. Dockerfile の編集

ここまで実行したコマンドを **Dockerfile** に記述します。

```docker:Dockerfile
FROM amazonlinux:2

RUN yum update -y \
  && yum install -y httpd \
  vim

RUN amazon-linux-extras install -y epel
RUN yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm

RUN yum clean metadata \
  && yum install -y \
  php81 php81-php php81-php-mbstring php81-php-pdo php81-php-xml \
  php81-php-fpm php81-php-mysqlnd php81-php-gd

RUN alternatives --install /usr/bin/php php /usr/bin/php81 1

RUN echo "<?php phpinfo();" > /var/www/html/info.php

CMD [ "apachectl", "-D", "FOREGROUND" ]
```

## 3-2. Docker イメージとコンテナの再作成

Docker コンテナを削除し、 Docker イメージを作り直して、 Docker コンテナを作成・起動します。

```bash
docker container rm -f advent-calendar
docker image build -t advent-calendar/advent-calendar:latest . 
docker container run -d --name advent-calendar -p 8080:80 advent-calendar/advent-calendar:latest
```

## 3-3. ブラウザでの PHP の設定情報の確認

http://localhost:8080/info.php にアクセスすると下記の画面が表示されます。

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/527226/20f81393-c322-c38b-9922-a0fcc08f01ab.png)

# おわりに

今回は、 **③ PHP 8.1 系のインストール** についての手順でした。

次回は、 **[④ Composer のインストール](https://qiita.com/ryamate/items/a8bbd003c6c2abceedc9)** の手順です。

ありがとうございました。

## 参考にしたサイト

https://aws.amazon.com/jp/premiumsupport/knowledge-center/ec2-install-extras-library-software/

https://dev.classmethod.jp/articles/how-to-work-with-amazon-linux2-amazon-linux-extras/

https://docs.fedoraproject.org/en-US/epel/epel-about/

https://www.geekfeed.co.jp/geekblog/centos-remi-epel-php#remi

https://qiita.com/enu1996502/items/e2a9f27b6522b5eaff0f

https://qiita.com/kyosuke5_20/items/b04813bb7ca26285d95e

https://qiita.com/reflet/items/11ad79e01e808876caa1

https://qiita.com/charon/items/f890ddbb66aa24d9bc38

https://qiita.com/tanaka-qtaro/items/0ee6359e46266ae9f608

https://vinelinux.org/docs/vine6/cui-guide/update-alternatives.html