CentOS 7にNginx 1.6をインストール（SCL）

# はじめに

Software Collection(SCL)を利用してCentOS7にNginx1.6をインストール
親記事：[Nginxの各種インストール方法とEOLまとめ](https://qiita.com/witchcraze/items/df4a0baaaad9c932ea30)
参考：[Quick Start — Software Collections](https://www.softwarecollections.org/en/docs/)

## サポート

本手法で導入した場合、[Red Hat Software Collections Product Life Cycle - Red Hat Customer Portal](https://access.redhat.com/support/policy/updates/rhscl)より、2016-10がEOLだと思われる。
それ以降に報告された脆弱性や不具合への対応は実施されない可能性がある。

## LOG

### レポジトリ登録

```shell-session
# yum install -y centos-release-scl
```

### インストール

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

# yum install -y nginx16 which
# scl enable nginx16 bash
... 略
```

### nginx起動/停止

```shell-session
# systemctl start nginx16-nginx
# systemctl status -l nginx16-nginx
● nginx16-nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx16-nginx.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-10-14 14:03:53 UTC; 4s ago
  Process: 246 ExecStart=/opt/rh/nginx16/root/usr/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 245 ExecStartPre=/opt/rh/nginx16/root/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
 Main PID: 247 (nginx)
   CGroup: /docker/f7ebd8cb7be633cd643c07169c77f8bc630b2e40a8d017b9b8077b5bef050811/system.slice/nginx16-nginx.service
           tq247 nginx: master process /opt/rh/nginx16/root/usr/sbin/nginx
           mq248 nginx: worker process
           ? 247 nginx: master process /opt/rh/nginx16/root/usr/sbin/nginx

Oct 14 14:03:52 f7ebd8cb7be6 systemd[1]: Starting The nginx HTTP and reverse proxy server...
Oct 14 14:03:52 f7ebd8cb7be6 nginx[245]: nginx: the configuration file /opt/rh/nginx16/root/etc/nginx/nginx.conf syntax is ok
Oct 14 14:03:52 f7ebd8cb7be6 nginx[245]: nginx: configuration file /opt/rh/nginx16/root/etc/nginx/nginx.conf test is successful
Oct 14 14:03:53 f7ebd8cb7be6 systemd[1]: Failed to read PID from file /opt/rh/nginx16/root/var/run/nginx/nginx.pid: Invalid argument
Oct 14 14:03:53 f7ebd8cb7be6 systemd[1]: Started The nginx HTTP and reverse proxy server.
```

```shell-session
# systemctl stop nginx16-nginx
# systemctl status -l nginx16-nginx
● nginx16-nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx16-nginx.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

Oct 14 14:03:52 f7ebd8cb7be6 systemd[1]: Starting The nginx HTTP and reverse proxy server...
Oct 14 14:03:52 f7ebd8cb7be6 nginx[245]: nginx: the configuration file /opt/rh/nginx16/root/etc/nginx/nginx.conf syntax is ok
Oct 14 14:03:52 f7ebd8cb7be6 nginx[245]: nginx: configuration file /opt/rh/nginx16/root/etc/nginx/nginx.conf test is successful
Oct 14 14:03:53 f7ebd8cb7be6 systemd[1]: Failed to read PID from file /opt/rh/nginx16/root/var/run/nginx/nginx.pid: Invalid argument
Oct 14 14:03:53 f7ebd8cb7be6 systemd[1]: Started The nginx HTTP and reverse proxy server.
Oct 14 14:04:24 f7ebd8cb7be6 systemd[1]: Stopping The nginx HTTP and reverse proxy server...
Oct 14 14:04:24 f7ebd8cb7be6 systemd[1]: Stopped The nginx HTTP and reverse proxy server.
```

### nginx自動起動設定/設定解除

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

# systemctl list-unit-files --type=service |grep nginx
nginx16-nginx.service                  enabled
```

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

# systemctl list-unit-files --type=service |grep nginx
nginx16-nginx.service                  disabled
```

### 各種確認

```shell-session
# which nginx
/opt/rh/nginx16/root/usr/sbin/nginx

# nginx -v
nginx version: nginx/1.6.2

# yum info nginx16
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: ftp.riken.jp
 * centos-sclo-rh: ftp.riken.jp
 * centos-sclo-sclo: ftp.riken.jp
 * extras: ftp.riken.jp
 * updates: ftp.riken.jp
Installed Packages
Name        : nginx16
Arch        : x86_64
Version     : 1.2
Release     : 2.el7
Size        : 0.0
Repo        : installed
From repo   : centos-sclo-rh
Summary     : Package that installs nginx16
License     : GPLv2+
Description : This is the main package for nginx16 Software Collection.
```