在centos安装php8.2报错
configure: error: *** A compiler with support for C++17 language features is required.
配置过程检测到你的系统编译器不支持 C++17 语言特性,而 PHP 8.2 的编译需要编译器支持 C++17
sudo yum update -y
sudo yum install centos-release-scl -y
sudo yum install devtoolset-8 -y
如果安装出现以下的报错:
centos No package devtoolset-8 available.
是因为centos7不支持安装gcc8及以上,因为它已经停止支持了,所以要更换源
修改CentOS-SCLo-scl.repo
|---|--------------------------------------------|
| | vi /etc/yum.repos.d/CentOS-SCLo-scl.repo
|
修改此部分的baseurl
|---|-------------------------------------------------------------------------------------|
| | [centos-sclo-sclo]
|
| | name=CentOS-7 - SCLo sclo
|
| | baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/sclo/
|
| | # mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-sclo
|
| | gpgcheck=0
|
| | enabled=1
|
| | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
|
修改CentOS-SCLo-scl-rh.repo
|---|-----------------------------------------------|
| | vi /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
|
修改此部分的baseurl
|---|-----------------------------------------------------------------------------------|
| | [centos-sclo-rh]
|
| | name=CentOS-7 - SCLo rh
|
| | baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/
|
| | # mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-rh
|
| | gpgcheck=0
|
| | enabled=1
|
| | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
|
刷新缓存
|---|-----------------|
| | yum repolist
|
| | yum clean all
|
| | yum makecache
|
最后再重新安装
sudo yum install centos-release-scl -y
sudo yum install devtoolset-8 -y
scl enable devtoolset-8 bash
如果要安装gcc9那就把8改成9
最后再重新回到原来的php安装就可以了