Sửa lỗi “Cannot find a valid baseurl for repo” trên CentOS 7 và update wget + openssl

Do CentOS 7 đã EOL nên nếu yum thì chỉ cài được bản 1.0.x, thỉnh thoảng gặp lỗi khi wget do openssl quá cũ

openssl cuối cùng được hỗ trợ trên CentOS 7 là 1.1.1

 

 

Prerequisites

yum -y update
yum groupinstall “Development Tools” -y
yum install gcc-c++ gnutls gnutls-devel -y
yum install -y make gcc perl-core pcre-devel wget zlib-devel

 

Sửa lỗi Cannot find a valid baseurl for repo

Nếu yum gặp lỗi Cannot find a valid baseurl for repo thì fix theo cách sau:

cd /etc/yum.repos.d

cp CentOS-Base.repo CentOS-Base.repo-bk

 

Trong CentOS-Base.repo, tắt mấy dòng mirrorlist đi, thay mấy link baseurl bằng:

[base]
baseurl=https://vault.centos.org/7.9.2009/os/$basearch/

[updates]
baseurl=https://vault.centos.org/7.9.2009/updates/$basearch/

[extras]
baseurl=https://vault.centos.org/7.9.2009/extras/$basearch/

[centosplus]
baseurl=http://vault.centos.org/7.9.2009/centosplus/$basearch/

 

Cập nhật openssl

Tải và cài openssl 1.1.1w

wget https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz

tar -xzvf openssl-1.1.1w.tar.gz
cd openssl-1.1.1w
./config –prefix=/usr/local/openssl

make

 

Có thể chạy “make test” trước cho chắc

make install

 

Tạo file /etc/profile.d/openssl.sh với nội dung sau:

export LD_LIBRARY_PATH=/usr/local/openssl/lib:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=/usr/local/openssl/lib/pkgconfig
export PATH=/usr/local/openssl/bin:$PATH

 

Lập tức áp dụng các cấu hình trong file openssl.sh

source /etc/profile.d/openssl.sh

 

Kiểm tra lại phiên bản openssl

openssl version

 

Cập nhật wget

Có thể wget vẫn dùng openssl ver trước đó, sẵn tiện cài luôn wget mới

Tải và cài wget phiên bản mới hơn

wget https://ftp.gnu.org/gnu/wget/wget-1.21.1.tar.gz
tar -xzvf wget-1.21.1.tar.gz
cd wget-1.21.1
./configure –with-ssl=openssl –with-libssl-prefix=/usr/local/openssl
make
make install

 

Ở bước ./configure trong lúc cài wget, nếu bị báo lỗi configure: error: –with-ssl=openssl was given, but SSL is not available thì

yum remove -y openssl-devel

make clean

Thực hiện lại từ bước ./configure

Was this helpful?

0 / 0