使用SCL在CentOS7上安装Nginx 1.6

首先

使用软件集合(Software Collection,简称SCL)在CentOS7上安装Nginx1.6。
主要文章:Nginx各种安装方式和EOL概述
参考:快速入门 — 软件集合

支持

如果采用这种方法进行导入,根据Red Hat客户门户网站上的Red Hat软件集合产品生命周期信息,可以推测2016年10月将到达服务终止(EOL)日期。之后可能不会执行对报告的漏洞和问题进行处理。

日志

仓库注册

# yum install -y centos-release-scl

安装

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

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

启动/停止Nginx。

# 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.
# 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

# 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
# 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

各种确认 –

# 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.