由于服务器定期漏洞扫描,nginx经常需要升级更新修复漏洞
先备份自己的nginx.conf和conf.d
vim /etc/yum.repos.d/nginx.repo
输入以下内容
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
看是否为最新版
yum info nginx
Installed Packages
Name : nginx
Arch : x86_64
Epoch : 1
Version : 1.16.1
Release : 1.el7
Size : 1.6 M
Repo : installed
From repo : epel
Summary : A high performance web server and reverse proxy server
URL : http://nginx.org/
License : BSD
Description : Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3 and
: IMAP protocols, with a strong focus on high concurrency, performance and low
: memory usage.
Available Packages
Name : nginx
Arch : x86_64
Epoch : 1
Version : 1.18.0
Release : 1.el7.ngx
Size : 772 k
Repo : nginx-stable/7/x86_64
Summary : High performance web server
URL : http://nginx.org/
License : 2-clause BSD-like license
Description : nginx [engine x] is an HTTP and reverse proxy server, as well as
: a mail proxy server.
升级nginx
yum update nginx
如果碰到 file /usr/lib64/nginx/modules/ngx_http_geoip_module.so from install of nginx-module-geoip-1:1.16.0-1.el7.ngx.x86_64 conflicts with file from package nginx-mod-http-geoip-1:1.12.2-3.el7.x86_64 这类模块错误。
yum remove nginx-mod*
yum install nginx-module-*
重新安装模块解决
再启动nginx
systemctl start nginx.service
官网文档:http://nginx.org/en/linux_packages.html#RHEL-CentOS