6

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?

0

4 Answers 4

5

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.

3
  • What exactly is docker-php-ext-install, and is it specific to certain distributions of linux?
    – laketuna
    Commented Feb 7, 2018 at 17:55
  • It's a command that's part of official PHP Docker Alpine images. See this repository: github.com/docker-library/php. You can see that it's doing stuff with apk, which is the package manager for Alpine Linux.
    – jjok
    Commented Feb 8, 2018 at 9:38
  • This answer will fail on an out-of-the-box Alpine install; you must first install libxml2-dev via apk for the the extension install to work, per the other answers.
    – Zane Claes
    Commented Sep 18, 2023 at 22:41
4

The solution is:

RUN set -ex && apk --no-cache add libxml2-dev
RUN docker-php-ext-install soap
1
  • I had to run "apk update" first to prevent error. Commented Mar 29, 2023 at 14:46
3

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>

-1

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

6
  • docker-php-ext commands are NEVER a part of Alpine. They are a part of Docker. Though the OP did not specify it, this question is Docker-specific.
    – Zane Claes
    Commented Sep 18, 2023 at 22:43
  • what makes you think I meant it oppositely from docker what OP and you meant? When I repeat after OP's docker command doesnt mean I imply docker command is missing from non docker where its evident (so strictly speaking even meaning it its logically sound),but that its also only on a subset of 'dockers' Just because I suggested a solution that works on both docker and non docker? Why to write 'Not every (DOCKER) alpine' instead of 'Not every alpine' for short, its you who says its evident from the question its docker based, so why I would reiterate word 'docker' along docker-php-ext?
    – FantomX1
    Commented Sep 19, 2023 at 22:05
  • @ZaneClaes fascinating you replied per se same 'apk' comment as me prior downvoting me - stackoverflow.com/q/48649837/3419535#comment135973312_48668565 'via apk for' ,right after comment referring docs that quasi refutes second part of your claim for alpine strictly speaking 'docker-php-ext commands are NEVER a part of Alpine' - stackoverflow.com/q/48649837/3419535##comment84361294_48668565 'docker-php-ext-install is a command that's part of official PHP Docker Alpine images' – github.com/docker-library/php/blob/master/8.1/alpine3.16/cli/… refuted by code
    – FantomX1
    Commented Sep 19, 2023 at 22:28
  • You seem to be conflating Docker and Alpine. They are two entirely orthogonal ideas; the code you are linking to does not belong to either Docker or Alpine. Of course, when you run a Docker Alpine image you have this command because the command is a bridge between Docker and the Alpine OS. In other words, it is only present for the special docker PHP+Alpine distro. So the idea of having php-ext-install as a command in normal old Alpine (as you suggested) is entirely nonsensical. This also explains why, as you said, it is not always present — because its not actually a part of Alpine itself.
    – Zane Claes
    Commented Sep 20, 2023 at 23:17
  • You did not address important part, addressed only the extremely residual marginal PS final notes that even didnt have to be there just informative which me myself marked flawed but from different view than you to begin with, the stuff what I wrote in the "dont use section" is not in some context complete, therefore the main part you didnt address the exact opposite of it of my response must be wrong . That part which I excluded was not exhausting not covering all the exclusive scenarios even those outside of the context of topic - unwitting strawman redhering -negation of negation is confirm
    – FantomX1
    Commented Sep 21, 2023 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.