0
0

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.18をインストール(SCL)

Last updated at Posted at 2021-07-12

はじめに

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

サポート

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

LOG

レポジトリ登録

# yum install -y centos-release-scl

インストール

1.16の時と同様、CentOS7.9だと起動しなかったので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-nginx118 which
# scl enable rh-nginx118 bash
... 略

nginx起動/停止

# systemctl start rh-nginx118-nginx
# systemctl status -l rh-nginx118-nginx
● rh-nginx118-nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/rh-nginx118-nginx.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2021-07-12 09:38:33 UTC; 11s ago
  Process: 1520 ExecStart=/opt/rh/rh-nginx118/root/usr/libexec/nginx-scl-helper enable $RH_NGINX118_SCLS_ENABLED -- /opt/rh/rh-nginx118/root/usr/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 1514 ExecStartPre=/opt/rh/rh-nginx118/root/usr/libexec/nginx-scl-helper enable $RH_NGINX118_SCLS_ENABLED -- /opt/rh/rh-nginx118/root/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 1507 ExecStartPre=/opt/rh/rh-nginx118/root/usr/libexec/nginx-scl-helper enable $RH_NGINX118_SCLS_ENABLED -- /usr/bin/scl_enabled rh-nginx118 (code=exited, status=0/SUCCESS)
  Process: 1506 ExecStartPre=/usr/bin/rm -f /var/opt/rh/rh-nginx118/run/nginx/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 1526 (nginx)
   CGroup: /docker/1bdd965407a521642054a14635e2612a29f2d348a44d418c605d4fdebc86322d/system.slice/rh-nginx118-nginx.service
           tq1526 nginx: master process /opt/rh/rh-nginx118/root/usr/sbin/nginx
           mq1527 nginx: worker process
           ? 1526 nginx: master process /opt/rh/rh-nginx118/root/usr/sbin/nginx

Jul 12 09:38:33 1bdd965407a5 systemd[1]: Starting The nginx HTTP and reverse proxy server...
Jul 12 09:38:33 1bdd965407a5 nginx-scl-helper[1514]: nginx: the configuration file /etc/opt/rh/rh-nginx118/nginx/nginx.conf syntax is ok
Jul 12 09:38:33 1bdd965407a5 nginx-scl-helper[1514]: nginx: configuration file /etc/opt/rh/rh-nginx118/nginx/nginx.conf test is successful
Jul 12 09:38:33 1bdd965407a5 systemd[1]: Failed to read PID from file /var/opt/rh/rh-nginx118/run/nginx/nginx.pid: Invalid argument
Jul 12 09:38:33 1bdd965407a5 systemd[1]: Started The nginx HTTP and reverse proxy server.
# systemctl stop rh-nginx118-nginx
# systemctl status -l rh-nginx118-nginx
● rh-nginx118-nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/rh-nginx118-nginx.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

Jul 12 09:38:33 1bdd965407a5 systemd[1]: Starting The nginx HTTP and reverse proxy server...
Jul 12 09:38:33 1bdd965407a5 nginx-scl-helper[1514]: nginx: the configuration file /etc/opt/rh/rh-nginx118/nginx/nginx.conf syntax is ok
Jul 12 09:38:33 1bdd965407a5 nginx-scl-helper[1514]: nginx: configuration file /etc/opt/rh/rh-nginx118/nginx/nginx.conf test is successful
Jul 12 09:38:33 1bdd965407a5 systemd[1]: Failed to read PID from file /var/opt/rh/rh-nginx118/run/nginx/nginx.pid: Invalid argument
Jul 12 09:38:33 1bdd965407a5 systemd[1]: Started The nginx HTTP and reverse proxy server.
Jul 12 09:39:12 1bdd965407a5 systemd[1]: Stopping The nginx HTTP and reverse proxy server...
Jul 12 09:39:12 1bdd965407a5 systemd[1]: Stopped The nginx HTTP and reverse proxy server.

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

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

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

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

各種確認

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

# nginx -v
nginx version: nginx/1.18.0

# yum info rh-nginx118
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: ty1.mirror.newmediaexpress.com
 * centos-sclo-rh: ty1.mirror.newmediaexpress.com
 * centos-sclo-sclo: ty1.mirror.newmediaexpress.com
 * extras: ty1.mirror.newmediaexpress.com
 * updates: ty1.mirror.newmediaexpress.com
Installed Packages
Name        : rh-nginx118
Arch        : x86_64
Version     : 1.18
Release     : 7.sc2.el7
Size        : 0.0
Repo        : installed
From repo   : centos-sclo-rh
Summary     : Package that installs rh-nginx118
License     : GPLv2+
Description : This is the main package for rh-nginx118 Software Collection.
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?