22
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

CentOS 7にNginx 1.16をインストール(SCL)

Last updated at Posted at 2020-01-30

はじめに

Software Collection(SCL)を利用してCentOS7にNginx1.16をインストール
親記事:Nginxの各種インストール方法とEOLまとめ
参考:Quick Start — Software Collections

サポート

本手法で導入した場合、Red Hat Software Collections Product Life Cycle - Red Hat Customer Portalより、2021-12がEOLだと思われる。
それ以降に報告された脆弱性や不具合への対応は実施されない可能性がある。

LOG

レポジトリ登録

# yum install -y centos-release-scl

インストール

CentOS7.7だと起動しなかったので7.6を使用しています。
Systemd error: 'Refusing to accept PID outside of service control group, acquired through unsafe symlink chain' - Red Hat Customer Portal が影響しているかもしれないけど未調査。

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

# yum install -y rh-nginx116 which
# scl enable rh-nginx116 bash
... 略

nginx起動/停止

# systemctl start rh-nginx116-nginx
# systemctl status -l rh-nginx116-nginx
● rh-nginx116-nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/rh-nginx116-nginx.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2020-01-30 03:30:15 UTC; 5s ago
  Process: 1431 ExecStart=/opt/rh/rh-nginx116/root/usr/libexec/nginx-scl-helper enable $RH_NGINX116_SCLS_ENABLED -- /opt/rh/rh-nginx116/root/usr/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 1425 ExecStartPre=/opt/rh/rh-nginx116/root/usr/libexec/nginx-scl-helper enable $RH_NGINX116_SCLS_ENABLED -- /opt/rh/rh-nginx116/root/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 1418 ExecStartPre=/opt/rh/rh-nginx116/root/usr/libexec/nginx-scl-helper enable $RH_NGINX116_SCLS_ENABLED -- /usr/bin/scl_enabled rh-nginx116 (code=exited, status=0/SUCCESS)
  Process: 1417 ExecStartPre=/usr/bin/rm -f /var/opt/rh/rh-nginx116/run/nginx/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 1437 (nginx)
   CGroup: /docker/285f4a924c86a08e019904bd193ea56b61ec9cf87e8fa795e3855778d20f6f4d/system.slice/rh-nginx116-nginx.service
           tq1437 nginx: master process /opt/rh/rh-nginx116/root/usr/sbin/nginx
           mq1438 nginx: worker process
           ? 1437 nginx: master process /opt/rh/rh-nginx116/root/usr/sbin/nginx

Jan 30 03:30:15 285f4a924c86 systemd[1]: Starting The nginx HTTP and reverse proxy server...
Jan 30 03:30:15 285f4a924c86 nginx-scl-helper[1425]: nginx: the configuration file /etc/opt/rh/rh-nginx116/nginx/nginx.conf syntax is ok
Jan 30 03:30:15 285f4a924c86 nginx-scl-helper[1425]: nginx: configuration file /etc/opt/rh/rh-nginx116/nginx/nginx.conf test is successful
Jan 30 03:30:15 285f4a924c86 systemd[1]: Failed to read PID from file /var/opt/rh/rh-nginx116/run/nginx/nginx.pid: Invalid argument
Jan 30 03:30:15 285f4a924c86 systemd[1]: Started The nginx HTTP and reverse proxy server.
# systemctl stop rh-nginx116-nginx
# systemctl status -l rh-nginx116-nginx
● rh-nginx116-nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/rh-nginx116-nginx.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

Jan 30 03:30:15 285f4a924c86 systemd[1]: Starting The nginx HTTP and reverse proxy server...
Jan 30 03:30:15 285f4a924c86 nginx-scl-helper[1425]: nginx: the configuration file /etc/opt/rh/rh-nginx116/nginx/nginx.conf syntax is ok
Jan 30 03:30:15 285f4a924c86 nginx-scl-helper[1425]: nginx: configuration file /etc/opt/rh/rh-nginx116/nginx/nginx.conf test is successful
Jan 30 03:30:15 285f4a924c86 systemd[1]: Failed to read PID from file /var/opt/rh/rh-nginx116/run/nginx/nginx.pid: Invalid argument
Jan 30 03:30:15 285f4a924c86 systemd[1]: Started The nginx HTTP and reverse proxy server.
Jan 30 03:30:46 285f4a924c86 systemd[1]: Stopping The nginx HTTP and reverse proxy server...
Jan 30 03:30:46 285f4a924c86 systemd[1]: Stopped The nginx HTTP and reverse proxy server.

CentOS7.7で発生したエラー

# systemctl start rh-nginx116-nginx
Job for rh-nginx116-nginx.service failed because a timeout was exceeded. See "systemctl status rh-nginx116-nginx.service" and "journalctl -xe" for details.
# systemctl status -l rh-nginx116-nginx.service
● rh-nginx116-nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/rh-nginx116-nginx.service; disabled; vendor preset: disabled)
   Active: failed (Result: timeout) since Thu 2020-01-30 03:37:24 UTC; 31s ago
  Process: 1744 ExecStart=/opt/rh/rh-nginx116/root/usr/libexec/nginx-scl-helper enable $RH_NGINX116_SCLS_ENABLED -- /opt/rh/rh-nginx116/root/usr/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 1738 ExecStartPre=/opt/rh/rh-nginx116/root/usr/libexec/nginx-scl-helper enable $RH_NGINX116_SCLS_ENABLED -- /opt/rh/rh-nginx116/root/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 1731 ExecStartPre=/opt/rh/rh-nginx116/root/usr/libexec/nginx-scl-helper enable $RH_NGINX116_SCLS_ENABLED -- /usr/bin/scl_enabled rh-nginx116 (code=exited, status=0/SUCCESS)
  Process: 1730 ExecStartPre=/usr/bin/rm -f /var/opt/rh/rh-nginx116/run/nginx/nginx.pid (code=exited, status=0/SUCCESS)
   CGroup: /docker/285f4a924c86a08e019904bd193ea56b61ec9cf87e8fa795e3855778d20f6f4d/docker/285f4a924c86a08e019904bd193ea56b61ec9cf87e8fa795e3855778d20f6f4d/system.slice/rh-nginx116-nginx.service
           tq1750 nginx: master process /opt/rh/rh-nginx116/root/usr/sbin/nginx
           mq1751 nginx: worker process

Jan 30 03:35:54 285f4a924c86 systemd[1]: Starting The nginx HTTP and reverse proxy server...
Jan 30 03:35:54 285f4a924c86 nginx-scl-helper[1738]: nginx: the configuration file /etc/opt/rh/rh-nginx116/nginx/nginx.conf syntax is ok
Jan 30 03:35:54 285f4a924c86 nginx-scl-helper[1738]: nginx: configuration file /etc/opt/rh/rh-nginx116/nginx/nginx.conf test is successful
Jan 30 03:35:54 285f4a924c86 systemd[1]: Failed to parse PID from file /var/opt/rh/rh-nginx116/run/nginx/nginx.pid: Invalid argument
Jan 30 03:35:54 285f4a924c86 systemd[1]: Refusing to accept PID outside of service control group, acquired through unsafe symlink chain: /var/opt/rh/rh-nginx116/run/nginx/nginx.pid
Jan 30 03:37:24 285f4a924c86 systemd[1]: rh-nginx116-nginx.service start operation timed out. Terminating.
Jan 30 03:37:24 285f4a924c86 systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Jan 30 03:37:24 285f4a924c86 systemd[1]: Unit rh-nginx116-nginx.service entered failed state.
Jan 30 03:37:24 285f4a924c86 systemd[1]: rh-nginx116-nginx.service failed.

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

# systemctl enable rh-nginx116-nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/rh-nginx116-nginx.service to /usr/lib/systemd/system/rh-nginx116-nginx.service.

# systemctl list-unit-files --type=service |grep nginx
rh-nginx116-nginx.service              enabled
# systemctl disable rh-nginx116-nginx
Removed symlink /etc/systemd/system/multi-user.target.wants/rh-nginx116-nginx.service.

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

各種確認

# which nginx
/opt/rh/rh-nginx116/root/usr/sbin/nginx

# nginx -v
nginx version: nginx/1.16.1

# yum info rh-nginx116
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        : rh-nginx116
Arch        : x86_64
Version     : 1.16
Release     : 1.el7
Size        : 0.0
Repo        : installed
From repo   : centos-sclo-rh
Summary     : Package that installs rh-nginx116
License     : GPLv2+
Description : This is the main package for rh-nginx116 Software Collection.
22
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?