在CentOS 7上通过软件集合(SCL)安装Nginx 1.12

首先

使用软件集(SCL)在CentOS7上安装Nginx1.12
原文链接:Nginx各种安装方法和EOL总结
参考链接:快速入门 — 软件集合

支持

如果使用这种方法,根据Red Hat软件集产品生命周期-Red Hat客户门户网站,2019-10年可能会成为终止支持版本。
之后可能不会对报告的漏洞和问题进行修复。

日志

仓库注册

# yum install -y centos-release-scl

安装

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

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

启动/停止Nginx。

# systemctl start rh-nginx112-nginx
# systemctl status -l rh-nginx112-nginx
● rh-nginx112-nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/rh-nginx112-nginx.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-10-14 14:27:10 UTC; 5s ago
  Process: 268 ExecStart=/opt/rh/rh-nginx112/root/usr/libexec/nginx-scl-helper enable $RH_NGINX112_SCLS_ENABLED -- /opt/rh/rh-nginx112/root/usr/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 262 ExecStartPre=/opt/rh/rh-nginx112/root/usr/libexec/nginx-scl-helper enable $RH_NGINX112_SCLS_ENABLED -- /opt/rh/rh-nginx112/root/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 255 ExecStartPre=/opt/rh/rh-nginx112/root/usr/libexec/nginx-scl-helper enable $RH_NGINX112_SCLS_ENABLED -- /usr/bin/scl_enabled rh-nginx112 (code=exited, status=0/SUCCESS)
  Process: 254 ExecStartPre=/usr/bin/rm -f /var/opt/rh/rh-nginx112/run/nginx/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 274 (nginx)
   CGroup: /docker/2c69eef17f35aea1cd6e32dc5c453e44d51d93a8ef2d4d12ffd2dacc24f90bf5/system.slice/rh-nginx112-nginx.service
           tq274 nginx: master process /opt/rh/rh-nginx112/root/usr/sbin/nginx
           mq275 nginx: worker process
           ? 274 nginx: master process /opt/rh/rh-nginx112/root/usr/sbin/nginx

Oct 14 14:27:10 2c69eef17f35 systemd[1]: Starting The nginx HTTP and reverse proxy server...
Oct 14 14:27:10 2c69eef17f35 nginx-scl-helper[262]: nginx: the configuration file /etc/opt/rh/rh-nginx112/nginx/nginx.conf syntax is ok
Oct 14 14:27:10 2c69eef17f35 nginx-scl-helper[262]: nginx: configuration file /etc/opt/rh/rh-nginx112/nginx/nginx.conf test is successful
Oct 14 14:27:10 2c69eef17f35 systemd[1]: Failed to read PID from file /var/opt/rh/rh-nginx112/run/nginx/nginx.pid: Invalid argument
Oct 14 14:27:10 2c69eef17f35 systemd[1]: Started The nginx HTTP and reverse proxy server.
# systemctl stop rh-nginx112-nginx
# systemctl status -l rh-nginx112-nginx
● rh-nginx112-nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/rh-nginx112-nginx.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

Oct 14 14:27:10 2c69eef17f35 systemd[1]: Starting The nginx HTTP and reverse proxy server...
Oct 14 14:27:10 2c69eef17f35 nginx-scl-helper[262]: nginx: the configuration file /etc/opt/rh/rh-nginx112/nginx/nginx.conf syntax is ok
Oct 14 14:27:10 2c69eef17f35 nginx-scl-helper[262]: nginx: configuration file /etc/opt/rh/rh-nginx112/nginx/nginx.conf test is successful
Oct 14 14:27:10 2c69eef17f35 systemd[1]: Failed to read PID from file /var/opt/rh/rh-nginx112/run/nginx/nginx.pid: Invalid argument
Oct 14 14:27:10 2c69eef17f35 systemd[1]: Started The nginx HTTP and reverse proxy server.
Oct 14 14:27:40 2c69eef17f35 systemd[1]: Stopping The nginx HTTP and reverse proxy server...
Oct 14 14:27:40 2c69eef17f35 systemd[1]: Stopped The nginx HTTP and reverse proxy server.

Nginx自动启动设置/设置解除

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

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

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

各种确认 (Gè

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

# nginx -v
nginx version: nginx/1.12.1

# yum info rh-nginx112
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-nginx112
Arch        : x86_64
Version     : 1.12
Release     : 3.el7
Size        : 0.0
Repo        : installed
From repo   : centos-sclo-rh
Summary     : Package that installs rh-nginx112
License     : GPLv2+
Description : This is the main package for rh-nginx112 Software Collection.
广告
将在 10 秒后关闭
bannerAds