【内网】服务器升级nginx1.17.0

今天用rpm包升级内网nginx版本,上来就给我报错

警告:nginx-1.27.0-2.el7.ngx.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 7bd9bf62: NOKEY

错误:依赖检测失败:

libcrypto.so.10()(64bit) 被 nginx-1:1.27.0-2.el7.ngx.x86_64 需要

libcrypto.so.10(OPENSSL_1.0.2)(64bit) 被 nginx-1:1.27.0-2.el7.ngx.x86_64 需要

libcrypto.so.10(libcrypto.so.10)(64bit) 被 nginx-1:1.27.0-2.el7.ngx.x86_64 需要

libssl.so.10()(64bit) 被 nginx-1:1.27.0-2.el7.ngx.x86_64 需要

libssl.so.10(libssl.so.10)(64bit) 被 nginx-1:1.27.0-2.el7.ngx.x86_64 需要

根据文章error: Failed dependencies libcrypto.so.10()(64bit) is needed, libssl.so.10()(64bit) is needed-CSDN博客

https://pkgs.org/download/libcrypto.so.10()(64bit)

下载新的包并且安装

然后又报了新的错

file /etc/logrotate.d/nginx from install of nginx-1:1.27.0-2.el7.ngx.x86_64 conflicts with file from package nginx-1:1.21.5-2.p01.ky10.x86_64

file /etc/nginx/nginx.conf from install of nginx-1:1.27.0-2.el7.ngx.x86_64 conflicts with file from package nginx-1:1.21.5-2.p01.ky10.x86_64

file /usr/lib/systemd/system/nginx.service from install of nginx-1:1.27.0-2.el7.ngx.x86_64 conflicts with file from package nginx-1:1.21.5-2.p01.ky10.x86_64

file /usr/sbin/nginx from install of nginx-1:1.27.0-2.el7.ngx.x86_64 conflicts with file from package nginx-1:1.21.5-2.p01.ky10.x86_64

file /usr/share/nginx/html/50x.html from install of nginx-1:1.27.0-2.el7.ngx.x86_64 conflicts with file from package nginx-1:1.21.5-2.p01.ky10.x86_64

file /usr/share/nginx/html/index.html from install of nginx-1:1.27.0-2.el7.ngx.x86_64 conflicts with file from package nginx-1:1.21.5-2.p01.ky10.x86_64

file /var/log/nginx from install of nginx-1:1.27.0-2.el7.ngx.x86_64 conflicts with file from package nginx-1:1.21.5-2.p01.ky10.x86_64

看意思是旧的nginx包依赖和新的包依赖冲突了

把旧的依赖包删了安装新的依赖包


整合脚本如下

bash 复制代码
#!/bin/bash

# 定义rpm包文件名
RPM_FILE="nginx-1.27.0-2.el7.ngx.x86_64.rpm"

# 检查是否为root用户
if [ "$EUID" -ne 0 ]; then
  echo "请使用root权限运行此脚本。"
  exit 1
fi

# 检查RPM文件是否存在
if [ ! -f "$RPM_FILE" ]; then
  echo "找不到文件 $RPM_FILE。请确保文件存在并重试。"
  exit 1
fi

# 备份当前配置文件
cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
cp -r /usr/lib64/nginx/modules/ /usr/lib64/nginx/modules_bak/
rm -rf modules

# 安装依赖
rpm -ivh "compat-openssl10-1.0.2o-8.ky10.x86_64.rpm"
echo "正在安装nginx..."

# 依赖包覆盖安装新的nginx
rpm -ivh --replacefiles "$RPM_FILE"
# 检查安装是否成功
if [ $? -eq 0 ]; then
  echo "nginx安装成功!"
else
  echo "nginx安装失败。请检查错误信息。"
  exit 1
fi

# 启动nginx服务
echo "正在启动nginx服务..."

/usr/sbin/nginx -c /etc/nginx/nginx.conf
/usr/sbin/nginx -s reload
systemctl daemon-reload
systemctl restart nginx


# 设置nginx开机自启动
echo "正在设置nginx开机自启动..."
systemctl enable nginx

echo "nginx安装和配置完成。"
相关推荐
MilesShi2 小时前
从 scheduler_tick 到上下文切换:深入解析 Linux 内核的 TIF_NEED_RESCHED 标志设置流程
linux·运维·单片机
我爱云计算5 小时前
K8S详解(5万字详细教程)
linux·运维·云原生·容器·kubernetes
2301_794333917 小时前
实验室服务器配置|通过Docker实现Linux系统多用户隔离与安全防控
linux·服务器·docker·实验室
荣光波比8 小时前
Nginx 实战系列(一)—— Web 核心概念、HTTP/HTTPS协议 与 Nginx 安装
linux·运维·服务器·nginx·云计算
绿箭柠檬茶11 小时前
Ubuntu 使用 Samba 共享文件夹
linux·运维·ubuntu
工藤新一¹12 小时前
Linux —— 虚拟进程地址空间
linux·运维·服务器·c/c++·虚拟进程地址空间
Aspiresky12 小时前
浅析Linux内核scatter-gather list实现
linux·dma·scatter/gather
奔跑吧 android13 小时前
【linux kernel 常用数据结构和设计模式】【数据结构 3】【模拟input子系统input_dev和input_handler之间的多对多关系】
linux·数据结构·input·kernel·input_dev·input_handler·input_handle
再难也得平13 小时前
Linux初级篇
linux·运维·服务器
小猫挖掘机(绝版)14 小时前
通过tailscale实现一台电脑上vscode通过ssh连接另一台电脑上的VMware Linux 虚拟机
linux·windows·vscode·ubuntu·ssh