从源代码安装 PHP 时,如何修复找不到 xml2-config 的错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19904083/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 20:13:31  来源:igfitidea点击:

How to fix error with xml2-config not found when installing PHP from sources?

phpcompilationphp-5.3

提问by TroodoN-Mike

When I try to install php 5.3 stable from source on Ubuntu (downloading compressed installation file from http://www.php.net/downloads.php) and I run ./configureI get this error:

当我尝试在 Ubuntu 上从源代码安装 php 5.3 stable(从http://www.php.net/downloads.php下载压缩安装文件)并运行时出现./configure此错误:

configure: error: xml2-config not found. Please check your libxml2 installation.

回答by TroodoN-Mike

All you need to do instal install package libxml2-dev for example:

你需要做的就是安装安装包 libxml2-dev 例如:

sudo apt-get install libxml2-dev

On CentOS/RHEL:

在 CentOS/RHEL 上:

sudo yum install libxml2-devel

回答by Максим Тарасенко

For the latest versions it is needed to install libxml++2.6-dev like that:

对于最新版本,需要像这样安装 libxml++2.6-dev:

apt-get install libxml++2.6-dev

回答by silver

I had the same issue when I used a DockerFile. My Docker is based on the php:5.5-apache image.

当我使用 DockerFile 时,我遇到了同样的问题。我的 Docker 基于 php:5.5-apache 镜像。

I got that error when executing the command "RUN docker-php-ext-install soap"

执行命令“RUN docker-php-ext-install soap”时出现该错误

I have solved it by adding the following command to my DockerFile

我已经通过将以下命令添加到我的 DockerFile 中解决了它

"RUN apt-get update && apt-get install -y libxml2-dev"

“运行 apt-get update && apt-get install -y libxml2-dev”

回答by Dmitry

Ubuntu, Debian:

Ubuntu、Debian:

sudo apt install libxml2-dev

Centos:

Centos:

sudo yum install libxml2-devel

回答by O. Kasule

OpenSuse

OpenSuse

"sudo zypper install libxml2-devel"

sudo zypper 安装 libxml2-devel

It will install any other dependencies or required packages/libraries

它将安装任何其他依赖项或所需的包/库

回答by Diego Padilla

this solution it gonna be ok on Redhat 8.0

这个解决方案在 Redhat 8.0 上没问题

sudo yum install libxml2-devel

须藤 yum 安装 libxml2-devel