此文档提供方法为官方源码build成rpm后,用rpm进行升级,在Centos7.5.1804下实现,其他环境未经测试(南网数据库环境为7.5.1804)。
1,
#下面内容可拷贝成脚本执行
#!/bin/bash
set -e
set -v
mkdir ~/openssl && cd ~/openssl
yum -y install \
curl \
which \
make \
gcc \
perl \
perl-WWW-Curl \
rpm-build
# Get openssl tarball
cp /root/openssl-1.1.1i.tar.gz ./
# SPEC file
cat << 'EOF' > ~/openssl/openssl.spec
Summary: OpenSSL 1.1.1i for Centos
Name: openssl
Version: %{?version}%{!?version:1.1.1i}
Release: 1%{?dist}
Obsoletes: %{name} <= %{version}
Provides: %{name} = %{version}
URL: https://www.openssl.org/
License: GPLv2+
Source: https://www.openssl.org/source/%{name}-%{version}.tar.gz
BuildRequires: make gcc perl perl-WWW-Curl
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
%global openssldir /usr/openssl
%description
OpenSSL RPM for version 1.1.1i on Centos
%package devel
Summary: Development files for programs which will use the openssl library
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
%description devel
OpenSSL RPM for version 1.1.1i on Centos (development package)
%prep
%setup -q
%build
./config --prefix=%{openssldir} --openssldir=%{openssldir}
make
%install
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
%make_install
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_libdir}
ln -sf %{openssldir}/lib/libssl.so.1.1 %{buildroot}%{_libdir}
ln -sf %{openssldir}/lib/libcrypto.so.1.1 %{buildroot}%{_libdir}
ln -sf %{openssldir}/bin/openssl %{buildroot}%{_bindir}
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
%files
%{openssldir}
%defattr(-,root,root)
/usr/bin/openssl
/usr/lib64/libcrypto.so.1.1
/usr/lib64/libssl.so.1.1
%files devel
%{openssldir}/include/*
%defattr(-,root,root)
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
EOF
mkdir -p /root/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
cp ~/openssl/openssl.spec /root/rpmbuild/SPECS/openssl.spec
mv openssl-1.1.1i.tar.gz /root/rpmbuild/SOURCES
cd /root/rpmbuild/SPECS && \
rpmbuild \
-D "version 1.1.1i" \
-ba openssl.spec
# Before Uninstall Openssl : rpm -qa openssl
# Uninstall Current Openssl Vesion : yum -y remove openssl
# For install: rpm -ivvh /root/rpmbuild/RPMS/x86_64/openssl-1.1.1i-1.el7.x86_64.rpm --nodeps
# Verify install: rpm -qa openssl
# openssl version
1. 安装包说明
[root@testserver3 tmp]# ls
openssl-1.1.1i.el7.offline.tar #U盘带此包
[root@testserver3 tmp]# tar xf openssl-1.1.1i.el7.offline.tar
[root@testserver3 tmp]# ls
openssl-1.1.1i.el7.offline openssl-1.1.1i.el7.offline.tar
[root@testserver3 tmp]# cd openssl-1.1.1i.el7.offline
[root@testserver3 openssl-1.1.1i.el7.offline]# ll
total 5636
-rw-r--r--. 1 root root 5395212 Jan 7 15:14 openssl-1.1.1i-1.el7.centos.x86_64.rpm
-rw-r--r--. 1 root root 133324 Jan 7 15:14 openssl-debuginfo-1.1.1i-1.el7.centos.x86_64.rpm
-rw-r--r--. 1 root root 234584 Jan 7 15:14 openssl-devel-1.1.1i-1.el7.centos.x86_64.rpm
[root@testserver3 openssl-1.1.1i.el7.offline]#
注:以上rpm包为根据官方源码包openssl-1.1.1i.tar.gz rpmbuild生成,本升级只用到openssl-1.1.1i-1.el7.centos.x86_64.rpm这个包。(rpmbuild打包脚本后面提供)
2.安装
2.1.安装前查看状态
[root@testserver3 openssl-1.1.1i.el7.offline]# rpm -aq openssl
openssl-1.0.2k-12.el7.x86_64
[root@testserver3 openssl-1.1.1i.el7.offline]# rpm -qa |grep openssl
openssl-libs-1.0.2k-12.el7.x86_64
openssl-1.0.2k-12.el7.x86_64
xmlsec1-openssl-1.2.20-7.el7_4.x86_64
2.2.卸载当前版本openssl
[root@testserver3 openssl-1.1.1i.el7.offline]# rpm -e openssl –nodeps
[root@testserver3 openssl-1.1.1i.el7.offline]# openssl
-bash: /usr/bin/openssl: No such file or directory
[root@testserver3 openssl-1.1.1i.el7.offline]# rpm -aq openssl
[root@testserver3 openssl-1.1.1i.el7.offline]#
[root@testserver3 openssl-1.1.1i.el7.offline]# rpm -qa |grep openssl
openssl-libs-1.0.2k-12.el7.x86_64
xmlsec1-openssl-1.2.20-7.el7_4.x86_64
2.3.安装新版本及验证
[root@testserver3 openssl-1.1.1i.el7.offline]# rpm -ivh openssl-1.1.1i-1.el7.centos.x86_64.rpm --nodeps
Preparing... ################################# [100%]
Updating / installing...
1:openssl-1.1.1i-1.el7.centos ################################# [100%]
[root@testserver3 openssl-1.1.1i.el7.offline]#
[root@testserver3 openssl-1.1.1i.el7.offline]#
[root@testserver3 openssl-1.1.1i.el7.offline]# rpm -aq openssl
openssl-1.1.1i-1.el7.centos.x86_64
[root@testserver3 openssl-1.1.1i.el7.offline]#
[root@testserver3 openssl-1.1.1i.el7.offline]# openssl version
OpenSSL 1.1.1i 8 Dec 2020
注:更新后要验证服务器可以正常登陆
来源:oschina
链接:https://my.oschina.net/u/4312833/blog/4888797