Reputation: 4080
I'm having issues trying to install and enable the PHP soap extension. I'm running the base image php:7.2-fpm-alpine3.6
inside a Docker container that has instructions like below in the Dockerfile
. It's unclear to me how extensions are installed on Alpine. It seems to use docker-php-ext-install
from what I can infer.
Dockerfile
(I adopted this from somewhere):
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.
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
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
. I searched under /usr/local/lib/php/extensions/no-debug-non-zts-20170718/
, and soap.so
was already there. Furthermore, my commands already enabled it for PHP-FPM. php -i
showed /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?
Upvotes: 6
Views: 15341
Reputation: 987
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>
Upvotes: 3
Reputation: 1711
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.
Anyway, any php extension can be easily installed by issuing this alpine install command to find any php extension
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
apk install php7-ldap
Upvotes: -1
Reputation: 51
The solution is:
RUN set -ex && apk --no-cache add libxml2-dev
RUN docker-php-ext-install soap
Upvotes: 4
Reputation: 619
The PHP SOAP extension requires the PHP XML extension, as documented here: http://php.net/manual/en/soap.requirements.php
I expect you need to install that first.
Presumably docker-php-ext-install xml
.
You shouldn't need to compile the XML library yourself as it will be part of the extension.
Upvotes: 5