Complete Guide to Installing CentOS 7/8 with Domestic Mirrors
CentOS 7 and CentOS 8 Installation Guide
Online Installation Guide for CentOS 7 and CentOS 8
For some special reasons, in specific situations, it is necessary to install CentOS 7 or CentOS 8. Since the official has discontinued these two versions and the mirror websites have been closed, normal installation may not be possible.
The reasons are as follows:
- Generally, there is a simple network installation version that downloads resources during the installation process. Usually within a 1GB ISO installation package.
- There is also a 10GB complete installation package that can directly complete the basic environment installation offline.
However, the tricky part is that we usually use the online installation package within 1GB and ultimately go for the minimal installation mode. But since the official mirror websites have been closed, the installation process will attempt to download metadata, causing the installation to fail.
It can still be resolved, and the solution is as follows:
Installing CentOS 7 and CentOS 8 Using Domestic Mirrors
Step 1: Modifying GUI Installation Parameters
When using GUI mode installation, it will pause at a configuration interface. Select the [Installation Source] option, open it, choose the HTTPS protocol, and then fill in the mirror site:
https://mirrors.nju.edu.cn/centos-vault/8.5.2111/BaseOS/x86_64/os/
Note that the nju.edu.cn mirror site is used here, but the version 8.5.2111 in the middle is important and must match the version of the ISO installation package you downloaded.
Taking version 8.5.2111 as an example, the address of its network installation package (usually X86_64 by default) is: https://mirrors.nju.edu.cn/centos-vault/8.5.2111/isos/x86_64/CentOS-8.5.2111-x86_64-boot.iso
Note that the version must match. Otherwise, an error will pop up during online installation, indicating a dependency library version mismatch.
Step 2: Modifying the Yum Source After Installation
After successful installation, directly running yum update
will not work and will result in an error. This is still because the official sources have been closed and need to be manually modified:
# First, replace the official repository with the mirror
find /etc/yum.repos.d -type f -name "*.repo" -exec sed -i 's|baseurl=http://mirror.centos.org|baseurl=https://mirrors.nju.edu.cn/centos-vault|g' {} +
# Then enable the default baseurl mirror switch to make it effective; we only modify the basic ones here, and you can enable other parts yourself
sed -i 's/^#baseurl=/baseurl=/g' /etc/yum.repos.d/CentOS-Linux-AppStream.repo \
/etc/yum.repos.d/CentOS-Linux-BaseOS.repo \
/etc/yum.repos.d/CentOS-Linux-Extras.repo \
/etc/yum.repos.d/CentOS-Linux-Extras-common.repo
# Special note: If it is a CentOS 8-Stream version, you need to change all Centos-Linux- files to Centos-Stream-
# A few files may not exist due to version reasons, and errors can be ignored, for example, /etc/yum.repos.d/CentOS-Linux-Extras-common.repo may not exist
# After execution, the yum command will return to normal