在CentOS 7上安装Nginx 1.14(使用SCL)

首先

使用软件收集(SCL)在CentOS7上安装Nginx1.14。
原文:Nginx的各种安装方法和EOL摘要
参考:快速入门 – 软件收集

支持

如果使用这种方法进行引入,根据红帽子客户门户的红帽子软件集合产品生命周期,2020年11月会被认为是终止支持(EOL)的时间点。之后可能不会执行对所报告的漏洞或问题的处理。

记录

提交存储库

# yum install -y centos-release-scl

安装

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

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

启动/停止nginx

# systemctl start rh-nginx114-nginx
# systemctl status -l rh-nginx114-nginx
● rh-nginx114-nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/rh-nginx114-nginx.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-10-14 14:36:31 UTC; 5s ago
  Process: 261 ExecStart=/opt/rh/rh-nginx114/root/usr/libexec/nginx-scl-helper enable $RH_NGINX114_SCLS_ENABLED -- /opt/rh/rh-nginx114/root/usr/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 255 ExecStartPre=/opt/rh/rh-nginx114/root/usr/libexec/nginx-scl-helper enable $RH_NGINX114_SCLS_ENABLED -- /opt/rh/rh-nginx114/root/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 248 ExecStartPre=/opt/rh/rh-nginx114/root/usr/libexec/nginx-scl-helper enable $RH_NGINX114_SCLS_ENABLED -- /usr/bin/scl_enabled rh-nginx114 (code=exited, status=0/SUCCESS)
  Process: 247 ExecStartPre=/usr/bin/rm -f /var/opt/rh/rh-nginx114/run/nginx/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 267 (nginx)
   CGroup: /docker/2cc91ff8098ff4fa30b7c7d9d0c76590afc75fe5e958b4ed1d3abebbca33d9ca/system.slice/rh-nginx114-nginx.service
           tq267 nginx: master process /opt/rh/rh-nginx114/root/usr/sbin/nginx
           mq268 nginx: worker process
           ? 267 nginx: master process /opt/rh/rh-nginx114/root/usr/sbin/nginx

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

Oct 14 14:36:31 2cc91ff8098f systemd[1]: Starting The nginx HTTP and reverse proxy server...
Oct 14 14:36:31 2cc91ff8098f nginx-scl-helper[255]: nginx: the configuration file /etc/opt/rh/rh-nginx114/nginx/nginx.conf syntax is ok
Oct 14 14:36:31 2cc91ff8098f nginx-scl-helper[255]: nginx: configuration file /etc/opt/rh/rh-nginx114/nginx/nginx.conf test is successful
Oct 14 14:36:31 2cc91ff8098f systemd[1]: Failed to read PID from file /var/opt/rh/rh-nginx114/run/nginx/nginx.pid: Invalid argument
Oct 14 14:36:31 2cc91ff8098f systemd[1]: Started The nginx HTTP and reverse proxy server.
Oct 14 14:36:54 2cc91ff8098f systemd[1]: Stopping The nginx HTTP and reverse proxy server...
Oct 14 14:36:54 2cc91ff8098f systemd[1]: Stopped The nginx HTTP and reverse proxy server.

自动启动nginx的配置/取消配置

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

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

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

各种确认 – gè

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

# nginx -v
nginx version: nginx/1.14.1

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