CentOS 7にPHP-FPM 7.2をインストール（Remi's RPM repository）

# はじめに

Remi's RPM repositoryを利用してCentOS7にPHP-FPM7.2をインストール
親記事：[PHP, PHP-FPMの各種インストール方法とEOLまとめ](https://qiita.com/witchcraze/items/dfe3823554b7caba6f6a)
参考：[Remi's RPM repository](https://rpms.remirepo.net/wizard/)

## サポート

本手法で導入した場合、[PHP: Supported Versions] (https://www.php.net/supported-versions.php)/[PHP: Unsupported Branches](https://www.php.net/eol.php)より、2020-11-30がEOLになると思われる。
それ以降に報告された脆弱性や不具合への対応は実施されない可能性がある。

## note

- インストール後の更新は`yum --enablerepo=remi-php72 update`

## LOG

### インストール

```shell-session
# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)

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

# yum install -y --enablerepo=remi-php72 php-fpm which
... 略
```

### php-fpm起動/停止

```shell-session
# systemctl start php-fpm
# systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
   Active: active (running) since Fri 2019-09-27 11:51:26 UTC; 5s ago
 Main PID: 984 (php-fpm)
   Status: "Ready to handle connections"
   CGroup: /docker/41c1773b7ab1fac1c8e380bf09510c776b54fff28c3d8fa6d16810a92686101c/docker/41c1773b7ab1fac1c8e380bf09510c776b54fff28c3d8fa6d16810a92686101c/system.slice/php-fpm.service
           tq984 php-fpm: master process (/etc/php-fpm.conf)
           tq985 php-fpm: pool www
           tq986 php-fpm: pool www
           tq987 php-fpm: pool www
           tq988 php-fpm: pool www
           mq989 php-fpm: pool www
           ? 984 php-fpm: master process (/etc/php-fpm.conf)

Sep 27 11:51:26 41c1773b7ab1 systemd[1]: Starting The PHP FastCGI Process Manager...
Sep 27 11:51:26 41c1773b7ab1 systemd[1]: Started The PHP FastCGI Process Manager.
```

```shell-session
# systemctl stop php-fpm
# systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

Sep 27 11:51:26 41c1773b7ab1 systemd[1]: Starting The PHP FastCGI Process Manager...
Sep 27 11:51:26 41c1773b7ab1 systemd[1]: Started The PHP FastCGI Process Manager.
Sep 27 11:51:53 41c1773b7ab1 systemd[1]: Stopping The PHP FastCGI Process Manager...
Sep 27 11:51:53 41c1773b7ab1 systemd[1]: Stopped The PHP FastCGI Process Manager.
```

### php-fpm自動起動設定/設定解除

```shell-session
# systemctl enable php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.

# systemctl list-unit-files --type=service |grep php-fpm
php-fpm.service                        enabled
```

```shell-session
# systemctl disable php-fpm
Removed symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service.

# systemctl list-unit-files --type=service |grep php-fpm
php-fpm.service                        disabled
```

### 各種確認

```shell-session
# which php
which: no php in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)

# which php-fpm
/usr/sbin/php-fpm

# php-fpm -v
PHP 7.2.23 (fpm-fcgi) (built: Sep 25 2019 07:40:10)
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

# yum info php-fpm
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.riken.jp
 * extras: ftp.iij.ad.jp
 * remi-safe: ftp.riken.jp
 * updates: ftp.iij.ad.jp
Installed Packages
Name        : php-fpm
Arch        : x86_64
Version     : 7.2.23
Release     : 1.el7.remi
Size        : 5.1 M
Repo        : installed
From repo   : remi-php72
Summary     : PHP FastCGI Process Manager
URL         : http://www.php.net/
License     : PHP and Zend and BSD and MIT and ASL 1.0 and NCSA
Description : PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI
            : implementation with some additional features useful for sites of
            : any size, especially busier sites.
```