在CentOS 7上安装Nginx 1.8(使用SCL)
首先
使用Software Collection(SCL)在CentOS7上安装Nginx1.8
参考来源:快速入门 — Software Collections
支持
据来自Red Hat Customer Portal的Red Hat Software Collections产品生命周期,如果采用本方法引入,预计2018年11月将成为其终止支持期限(EOL)。
之后可能不会对报告的漏洞和问题进行修复。
记录
注册仓库
# yum install -y centos-release-scl
安装
# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
# yum install -y rh-nginx18 which
# scl enable rh-nginx18 bash
... 略
启动/停止NGINX
# systemctl start rh-nginx18-nginx
# systemctl status -l rh-nginx18-nginx
● rh-nginx18-nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/rh-nginx18-nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2019-10-14 14:12:03 UTC; 4s ago
Process: 247 ExecStart=/opt/rh/rh-nginx18/root/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 246 ExecStartPre=/opt/rh/rh-nginx18/root/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Main PID: 248 (nginx)
CGroup: /docker/02ec5261bfda015f3e9817c10121b773bc53984a065bf6d10c30e3e740b346c1/system.slice/rh-nginx18-nginx.service
tq248 nginx: master process /opt/rh/rh-nginx18/root/usr/sbin/nginx
mq249 nginx: worker process
? 248 nginx: master process /opt/rh/rh-nginx18/root/usr/sbin/nginx
Oct 14 14:12:03 02ec5261bfda systemd[1]: Starting The nginx HTTP and reverse proxy server...
Oct 14 14:12:03 02ec5261bfda nginx[246]: nginx: the configuration file /etc/opt/rh/rh-nginx18/nginx/nginx.conf syntax is ok
Oct 14 14:12:03 02ec5261bfda nginx[246]: nginx: configuration file /etc/opt/rh/rh-nginx18/nginx/nginx.conf test is successful
Oct 14 14:12:03 02ec5261bfda systemd[1]: Failed to read PID from file /var/opt/rh/rh-nginx18/run/nginx/nginx.pid: Invalid argument
Oct 14 14:12:03 02ec5261bfda systemd[1]: Started The nginx HTTP and reverse proxy server.
# systemctl stop rh-nginx18-nginx
# systemctl status -l rh-nginx18-nginx
● rh-nginx18-nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/rh-nginx18-nginx.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Oct 14 14:12:03 02ec5261bfda systemd[1]: Starting The nginx HTTP and reverse proxy server...
Oct 14 14:12:03 02ec5261bfda nginx[246]: nginx: the configuration file /etc/opt/rh/rh-nginx18/nginx/nginx.conf syntax is ok
Oct 14 14:12:03 02ec5261bfda nginx[246]: nginx: configuration file /etc/opt/rh/rh-nginx18/nginx/nginx.conf test is successful
Oct 14 14:12:03 02ec5261bfda systemd[1]: Failed to read PID from file /var/opt/rh/rh-nginx18/run/nginx/nginx.pid: Invalid argument
Oct 14 14:12:03 02ec5261bfda systemd[1]: Started The nginx HTTP and reverse proxy server.
Oct 14 14:12:24 02ec5261bfda systemd[1]: Stopping The nginx HTTP and reverse proxy server...
Oct 14 14:12:24 02ec5261bfda systemd[1]: Stopped The nginx HTTP and reverse proxy server.
自動启动/取消Nginx的设置。
# systemctl enable rh-nginx18-nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/rh-nginx18-nginx.service to /usr/lib/systemd/system/rh-nginx18-nginx.service.
# systemctl list-unit-files --type=service |grep nginx
rh-nginx18-nginx.service enabled
# systemctl disable rh-nginx18-nginx
Removed symlink /etc/systemd/system/multi-user.target.wants/rh-nginx18-nginx.service.
# systemctl list-unit-files --type=service |grep nginx
rh-nginx18-nginx.service disabled
各种确认 (Gè
# which nginx
/opt/rh/rh-nginx18/root/usr/sbin/nginx
# nginx -v
nginx version: nginx/1.8.1
# yum info rh-nginx18
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* centos-sclo-rh: ftp.iij.ad.jp
* centos-sclo-sclo: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Installed Packages
Name : rh-nginx18
Arch : x86_64
Version : 2.1
Release : 4.el7
Size : 0.0
Repo : installed
From repo : centos-sclo-rh
Summary : Package that installs rh-nginx18
License : GPLv2+
Description : This is the main package for rh-nginx18 Software Collection.