nginx安装升级更新

[root@test_db1 ~]# cd /home/software
[root@test_db1 software]# 
[root@test_db1 software]# 
[root@test_db1 software]# wget http://nginx.org/packages/rhel/7/x86_64/RPMS/nginx-1.22.0-1.el7.ngx.x86_64.rpm
--2022-08-01 12:58:54--  http://nginx.org/packages/rhel/7/x86_64/RPMS/nginx-1.22.0-1.el7.ngx.x86_64.rpm
正在解析主机 nginx.org (nginx.org)... 52.58.199.22, 3.125.197.172, 2a05:d014:edb:5702::6, ...
正在连接 nginx.org (nginx.org)|52.58.199.22|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:815252 (796K) [application/x-redhat-package-manager]
正在保存至: “nginx-1.22.0-1.el7.ngx.x86_64.rpm”

100%[===============================================================================================================================================================>] 815,252      238KB/s 用时 3.3s   

2022-08-01 12:58:58 (238 KB/s) - 已保存 “nginx-1.22.0-1.el7.ngx.x86_64.rpm” [815252/815252])

[root@test_db1 software]# 
[root@test_db1 software]# wget http://www6.atomicorp.com/channels/atomic/centos/7/x86_64/RPMS/pcre2-10.23-2.el7.art.x86_64.rpm
--2022-08-01 12:59:05--  http://www6.atomicorp.com/channels/atomic/centos/7/x86_64/RPMS/pcre2-10.23-2.el7.art.x86_64.rpm
正在解析主机 www6.atomicorp.com (www6.atomicorp.com)... 51.161.13.101, 51.79.80.20
正在连接 www6.atomicorp.com (www6.atomicorp.com)|51.161.13.101|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:206264 (201K) [application/x-rpm]
正在保存至: “pcre2-10.23-2.el7.art.x86_64.rpm”

 8% [============>                                                                                                                                                   ] 17,072      47.8KB/s             
100%[===============================================================================================================================================================>] 206,264      185KB/s 用时 1.1s   

2022-08-01 12:59:09 (185 KB/s) - 已保存 “pcre2-10.23-2.el7.art.x86_64.rpm” [206264/206264])

[root@test_db1 software]# 
[root@test_db1 software]# 
[root@test_db1 software]# rpm -Uvh pcre2-10.23-2.el7.art.x86_64.rpm
警告:pcre2-10.23-2.el7.art.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 4520afa9: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:pcre2-10.23-2.el7.art            ################################# [100%]
[root@test_db1 software]# 
[root@test_db1 software]# rpm -Uvh nginx-1.22.0-1.el7.ngx.x86_64.rpm
警告:nginx-1.22.0-1.el7.ngx.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 7bd9bf62: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:nginx-1:1.22.0-1.el7.ngx         ################################# [100%]
----------------------------------------------------------------------

Thanks for using nginx!

Please find the official documentation for nginx here:
* https://nginx.org/en/docs/

Please subscribe to nginx-announce mailing list to get
the most important news about nginx:
* https://nginx.org/en/support.html

Commercial subscriptions for nginx are available on:
* https://nginx.com/products/

----------------------------------------------------------------------
[root@test_db1 software]# 
[root@test_db1 software]# systemctl restart nginx
[root@test_db1 software]# 
[root@test_db1 software]# systemctl status nginx
● nginx.service - nginx - high performance web server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: active (running) since 一 2022-08-01 13:00:09 CST; 10s ago
     Docs: http://nginx.org/en/docs/
  Process: 27766 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
 Main PID: 27767 (nginx)
   CGroup: /system.slice/nginx.service
           ├─27767 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
           ├─27768 nginx: worker process
           ├─27769 nginx: worker process
           ├─27770 nginx: worker process
           ├─27771 nginx: worker process
           ├─27772 nginx: worker process
           ├─27773 nginx: worker process
           ├─27774 nginx: worker process
           ├─27775 nginx: worker process
           ├─27776 nginx: worker process
           ├─27777 nginx: worker process
           ├─27778 nginx: worker process
           ├─27780 nginx: worker process
           ├─27781 nginx: worker process
           ├─27783 nginx: worker process
           ├─27785 nginx: worker process
           └─27786 nginx: worker process

8月 01 13:00:09 test_db1 systemd[1]: Starting nginx - high performance web server...
8月 01 13:00:09 test_db1 systemd[1]: Started nginx - high performance web server.
[root@test_db1 software]# 
[root@test_db1 software]# 

########################################################################################
https://pkgs.org/download/libpcre2-8.so.0()(64bit)
https://centos.pkgs.org/7/centos-aarch64/pcre2-10.23-2.el7.aarch64.rpm.html
https://centos.pkgs.org/7/atomic-x86_64/pcre2-10.23-2.el7.art.x86_64.rpm.html

Install Howto
Download latest atomic-release rpm from
http://www6.atomicorp.com/channels/atomic/centos/7/x86_64/RPMS/
Install atomic-release rpm:
# rpm -Uvh atomic-release*rpm
Install pcre2 rpm package:
# yum install pcre2


rpm -qa|grep nginx

##########################################################################################
利用 yum 命令和 rpm 命令升级 Nginx 或者安装最新版本 Nginx
方法一:使用 yum 命令升级 Nginx
1、在配置 YUM 仓库的目录(/etc/yum.repos.d/)下新增文件  nginx.repo

vi /etc/yum.repos.d/nginx.repo
     nginx.repo 文件的内容如下:

# nginx.repo

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
2、然后执行 yum clean all  和 yum makecache 命令

3、开始升级 nginx

yum update nginx          # 升级 Nginx
方法二:在方法一的基础上,先卸载后安装
1、卸载: yum remove nginx

2、安装: yum install nginx -y

方法三:下载Nginx官网的指定rpm包,使用 rpm 命令升级
Nginx官方的  rpm包地址:http://nginx.org/packages/rhel/7/x86_64/RPMS/

1、可以直接升级指定 nginx 版本: 

#先下载nginx的rpm包
[root@test soft]# wget http://nginx.org/packages/rhel/7/x86_64/RPMS/nginx-1.22.0-1.el7.ngx.x86_64.rpm

# 再执行 rpm -Uvh nginx-1.12***
[root@test soft]# rpm -Uvh nginx-1.22.0-1.el7.ngx.x86_64.rpm 
warning: nginx-1.12.0-1.el7.ngx.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:nginx-1.22.0-1.el7.ngx         ################################# [ 50%]
Cleaning up / removing...
   2:nginx-1:1.6.3-8.el7              ################################# [100%]

# 升级后
[root@test soft]# rpm -qa|grep nginx
nginx-1.22.0-1.el7.ngx.x86_64

### 使用RPM包升级Nginx服务器 为了使用RPM包来升级Nginx服务器,可以按照如下方法操作: 确保当前系统的软件库是最新的。这可以通过运行 `yum update` 来完成[^1]。 卸载旧版本的 Nginx 是必要的以防存在冲突。此过程可通过命令 `yum remove nginx` 实现。 下载适用于目标操作系统版本的新版 Nginx RPM 包。如果已经获取了新版本的 RPM 文件,则可跳过这一步骤并直接进入安装阶段[^2]。 利用测试选项检查即将安装的 RPM 是否缺少任何依赖关系,该命令为 `rpm -ivh --test nginx-<version>.el7.ngx.x86_64.rpm` 。这里 `<version>` 应替换为实际要安装的具体版本号。 一旦确认所有必需的依赖项都已满足,就可以正式执行安装更新命令:`rpm -Uvh nginx-<version>.el7.ngx.x86_64.rpm` ,其中 `-U` 表示升级现有程序包;而 `-v` 和 `-h` 则分别用于显示详细信息以及进度条。 最后重启 Nginx 服务使更改生效,即输入 `systemctl restart nginx` 或者对于较老的操作系统可能是 `/etc/init.d/nginx restart`[^3]。 ```bash # 更新系统中的所有软件包到最新版本 sudo yum update # 卸载现有的 Nginx 版本(如果有) sudo yum remove nginx # 测试安装前验证依赖关系 (假设文件名为 nginx-1.18.0-1.el7.ngx.x86_64.rpm) sudo rpm -ivh --test nginx-1.18.0-1.el7.ngx.x86_64.rpm # 正式进行 Nginx安装/升级 sudo rpm -Uvh nginx-1.18.0-1.el7.ngx.x86_64.rpm # 重新启动 Nginx 服务以应用变更 sudo systemctl restart nginx ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值