RHEL 8にNginx 1.16をインストール（AppStream）

# はじめに

Application Stream(AppStream)を利用してRHEL8にNginx1.16をインストール
親記事：[Nginxの各種インストール方法とEOLまとめ](https://qiita.com/witchcraze/items/df4a0baaaad9c932ea30)
参考：[RHEL8のパッケージ構成 - BaseOSとApplication Stream - 赤帽エンジニアブログ]( https://rheb.hatenablog.com/entry/rhel8_baseos_and_appstream)

## サポート

本手法で導入した場合、[Red Hat Enterprise Linux 8 Application Streams Life Cycle - Red Hat Customer Portal](https://access.redhat.com/node/4079021)より、2021-11がEOLだと思われる。→ RHEL8.6リリース後に2021-10に変更された。
それ以降に報告された脆弱性や不具合への対応は実施されない可能性がある。

## LOG

### インストール

```shell-session
# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.1 (Ootpa)

# yum module reset nginx
# yum install -y @nginx:1.16
... 略
```

### nginx起動/停止

```shell-session
# systemctl start nginx
# systemctl status -l nginx
● nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/nginx.service.d
           mqphp-fpm.conf
   Active: active (running) since Sun 2019-11-10 09:17:38 UTC; 5s ago
  Process: 246 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 245 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 244 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 252 (nginx)
    Tasks: 2 (limit: 4630)
   Memory: 3.9M
   CGroup: /machine.slice/libpod-a51be7a790a7cf00b566988dba2d9ee826463fffae0c67dd43a00d6deb31d231.scope/system
.slice/nginx.service
           tq252 nginx: master process /usr/sbin/nginx
           mq253 nginx: worker process

Nov 10 09:17:38 a51be7a790a7 systemd[1]: Starting The nginx HTTP and reverse proxy server...
Nov 10 09:17:38 a51be7a790a7 nginx[245]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Nov 10 09:17:38 a51be7a790a7 nginx[245]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Nov 10 09:17:38 a51be7a790a7 systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid
argument
Nov 10 09:17:38 a51be7a790a7 systemd[1]: Started The nginx HTTP and reverse proxy server.
```

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

Nov 10 09:17:33 a51be7a790a7 systemd[1]: nginx.service: Unit cannot be reloaded becaus
e it is inactive.
Nov 10 09:17:33 a51be7a790a7 systemd[1]: nginx.service: Unit cannot be reloaded becaus
e it is inactive.
Nov 10 09:17:35 a51be7a790a7 systemd[1]: nginx.service: Unit cannot be reloaded becaus
e it is inactive.
Nov 10 09:17:38 a51be7a790a7 systemd[1]: Starting The nginx HTTP and reverse proxy server...
Nov 10 09:17:38 a51be7a790a7 nginx[245]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Nov 10 09:17:38 a51be7a790a7 nginx[245]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Nov 10 09:17:38 a51be7a790a7 systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid
argument
Nov 10 09:17:38 a51be7a790a7 systemd[1]: Started The nginx HTTP and reverse proxy server.
Nov 10 09:18:03 a51be7a790a7 systemd[1]: Stopping The nginx HTTP and reverse proxy server...
Nov 10 09:18:03 a51be7a790a7 systemd[1]: Stopped The nginx HTTP and reverse proxy server.
```

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

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

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

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

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

### 各種確認

```shell-session
# which nginx
/usr/sbin/nginx

# nginx -v
nginx version: nginx/1.16.1

# yum module info nginx:1.16
Updating Subscription Management repositories.
Unable to read consumer identity
Subscription Manager is operating in container mode.
Last metadata expiration check: 0:02:54 ago on Sun Nov 10 09:16:37 2019.
Name             : nginx
Stream           : 1.16 [e] [a]
Version          : 8010020190829151810
Context          : cdc1202b
Architecture     : x86_64
Profiles         : common [d] [i]
Default profiles : common
Repo             : rhel-8-for-x86_64-appstream-rpms
Summary          : nginx webserver
Description      : nginx 1.16 webserver module
Artifacts        : nginx-1:1.16.1-1.module+el8.1.0+4097+739b0d87.src
                 : nginx-1:1.16.1-1.module+el8.1.0+4097+739b0d87.x86_64
                 : nginx-all-modules-1:1.16.1-1.module+el8.1.0+4097+739b0d87.noarch
                 : nginx-debuginfo-1:1.16.1-1.module+el8.1.0+4097+739b0d87.x86_64
                 : nginx-debugsource-1:1.16.1-1.module+el8.1.0+4097+739b0d87.x86_64
                 : nginx-filesystem-1:1.16.1-1.module+el8.1.0+4097+739b0d87.noarch
                 : nginx-mod-http-image-filter-1:1.16.1-1.module+el8.1.0+4097+739b0d87.x86_64
                 : nginx-mod-http-image-filter-debuginfo-1:1.16.1-1.module+el8.1.0+4097+739b0d87.x86_64
                 : nginx-mod-http-perl-1:1.16.1-1.module+el8.1.0+4097+739b0d87.x86_64
                 : nginx-mod-http-perl-debuginfo-1:1.16.1-1.module+el8.1.0+4097+739b0d87.x86_64
                 : nginx-mod-http-xslt-filter-1:1.16.1-1.module+el8.1.0+4097+739b0d87.x86_64
                 : nginx-mod-http-xslt-filter-debuginfo-1:1.16.1-1.module+el8.1.0+4097+739b0d87.x86_64
                 : nginx-mod-mail-1:1.16.1-1.module+el8.1.0+4097+739b0d87.x86_64
                 : nginx-mod-mail-debuginfo-1:1.16.1-1.module+el8.1.0+4097+739b0d87.x86_64
                 : nginx-mod-stream-1:1.16.1-1.module+el8.1.0+4097+739b0d87.x86_64
                 : nginx-mod-stream-debuginfo-1:1.16.1-1.module+el8.1.0+4097+739b0d87.x86_64

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