[英]How to install PHP soap extension on Alpine 3.6
I'm having issues trying to install and enable the PHP soap extension.我在尝试安装和启用 PHP soap 扩展时遇到问题。 I'm running the base image
php:7.2-fpm-alpine3.6
inside a Docker container that has instructions like below in the Dockerfile
.我正在一个 Docker 容器中运行基本图像
php:7.2-fpm-alpine3.6
,该容器在Dockerfile
中有如下指令。 It's unclear to me how extensions are installed on Alpine.我不清楚如何在 Alpine 上安装扩展。 It seems to use
docker-php-ext-install
from what I can infer.根据我的推断,它似乎使用了
docker-php-ext-install
。
Dockerfile
(I adopted this from somewhere): Dockerfile
(我从某个地方采用了这个):
RUN apk --no-cache add \
freetype libpng libjpeg-turbo freetype-dev libpng-dev libjpeg-turbo-dev \
wget \
git \
nginx \
ca-certificates \
supervisor \
bash \
nano \
&& docker-php-ext-install \
mysqli \
pdo_mysql \
opcache \
...
So, I tried所以,我试过了
docker-php-ext-install soap
which told me configure: error: xml2-config not found. Please check your libxml2 installation.
这告诉我
configure: error: xml2-config not found. Please check your libxml2 installation.
configure: error: xml2-config not found. Please check your libxml2 installation.
I tried a bunch of stuff, but我尝试了很多东西,但是
apk add --no-cache libxml2-dev
seemed to do something.似乎做了什么。 I followed this again with
docker-php-ext-install soap
, which outputted我再次使用
docker-php-ext-install soap
,其输出
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/
find . -name \*.gcno -o -name \*.gcda | xargs rm -f
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp.la modules/* libs/*
At this point, I did not run make test
, as it's unclear where I'm suppose to go find this Makefile
.在这一点上,我没有运行
make test
,因为我不清楚我应该去哪里找到这个Makefile
。 I searched under /usr/local/lib/php/extensions/no-debug-non-zts-20170718/
, and soap.so
was already there.我在
/usr/local/lib/php/extensions/no-debug-non-zts-20170718/
, soap.so
已经在那里了。 Furthermore, my commands already enabled it for PHP-FPM.此外,我的命令已经为 PHP-FPM 启用了它。
php -i
showed /usr/local/etc/php/conf.d/docker-php-ext-soap.ini,
. php -i
显示/usr/local/etc/php/conf.d/docker-php-ext-soap.ini,
.
I'm not entirely sure what I did.我不完全确定我做了什么。 Is this (
docker-php-ext-install
) how you install extensions on this OS?这是(
docker-php-ext-install
)你如何在这个操作系统上安装扩展?
The PHP SOAP extension requires the PHP XML extension, as documented here: http://php.net/manual/en/soap.requirements.php PHP SOAP 扩展需要 PHP XML 扩展,如此处所述: http : //php.net/manual/en/soap.requirements.php
I expect you need to install that first.我希望您需要先安装它。
Presumably docker-php-ext-install xml
.大概是
docker-php-ext-install xml
。
You shouldn't need to compile the XML library yourself as it will be part of the extension.您不需要自己编译 XML 库,因为它将成为扩展的一部分。
You can add a utility to your image using this package您可以使用此包向您的图像添加实用程序
Example:示例:
FROM php:7.2-cli
ADD https://raw.githubusercontent.com/mlocati/docker-php-extension-installer/master/install-php-extensions /usr/local/bin/
RUN chmod uga+x /usr/local/bin/install-php-extensions && sync && \
install-php-extensions gd xdebug
If you want, you can remove the last line and enter the container to play around with adding packages.如果需要,您可以删除最后一行并进入容器以添加包。
docker exec -it <container_id> bash # (swap bash for sh if using alpine)
Then you can just type install-php-extensions <ext>
然后你可以输入
install-php-extensions <ext>
The solution is:解决办法是:
RUN set -ex && apk --no-cache add libxml2-dev
RUN docker-php-ext-install soap
Not every alpine distribution contains docker-php-ext commands etc, and I don't know how to add them easily, it did not look simple at all to me.并非每个 alpine 发行版都包含 docker-php-ext 命令等,而且我不知道如何轻松添加它们,对我来说它看起来一点也不简单。
Anyway, any php extension can be easily installed by issuing this alpine install command to find any php extension无论如何,通过发出此 alpine install 命令来查找任何 php 扩展,可以轻松安装任何 php 扩展
apk search -v 'php' |grep ldap
result结果
phpldapadmin-1.2.3-r4 - Web front-end for managing OpenLDAP
php7-ldap-7.2.22-r0 - PHP7 extension: LDAP
php5-ldap-5.6.40-r0 - ldap extension for PHP
to further install the extension, one must supply its name in a form without the suffix version part , eg.要进一步安装扩展,必须以一种没有后缀版本部分的形式提供其名称,例如。 without
-7.2.22-r0
in php7-ldap-7.2.22-r0
so it's php7-ldap
like this没有
-7.2.22-r0
在php7-ldap-7.2.22-r0
所以它的php7-ldap
这样
apk install php7-ldap
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.