If the current operating system is CentOs and it is newly installed after 2022, there may be a method that php cannot be installed.
Although the message list shows that the installation is complete like this, it is not installed at all. In the software store - the newly installed php version cannot be found in the installed list
You can check the error message in the log (this error message will appear when you choose to compile and install)
error: C++ preprocessor "/lib/cpp" fails sanity check
It's missing a necessary C++ library. Run, the following command solves
yum install glibc-headers
yum install gcc-c++
At this time, an error like this should be prompted: Error: Failed to download metadata for repo 'powertools': Cannot prepare internal mirrorlist: No URLs in mirrorlist
reason:
CentOS Linux 8 reached End of Life (EOL) on December 31, 2021. This means that CentOS 8 will no longer receive development resources from the official CentOS project. More information can be found in the official CentOS announcement. If you need to update CentOS, you need to change the mirror from mirror.centos.org to vault.centos.org
solve:
1. First update the yum source to Ali's
// 看当前的Centos系统是哪个版本的就选择对应的版本安装,这里以Centos8为例
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
2. Modify the content of the centos file
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
3. Generate cache updates
yum clean all
yum makecache
If you get this error: Failed to set locale, defaulting to C.UTF-8
Execute the following two commands to solve the problem, and then regenerate the cache update
echo "export LC_ALL=en_US.UTF8" >> /etc/profile
source /etc/profile
4. Run yum update
yum update -y
5. Reinstall the C++ library, there should be no error
yum install glibc-headers
yum install gcc-c++
At this time, go to the software store to install the corresponding php version should be normal~