问题
I am trying to install/enable the PHP http extension on my PHP alpine image.
My composer.json
file for my application contains "ext-http": "*"
, hence my goal.
My Dockerfile (relevant portions) is as follows:
# PHP-FPM Base Image
FROM php:7.2.26-fpm-alpine
# Install PHP extensions
RUN apk add --update --virtual .build-deps autoconf g++ make zlib-dev curl-dev \
&& pecl install raphf propro \
&& docker-php-ext-enable raphf propro \
&& pecl install pecl_http \
&& echo -e "extension=raphf.so\nextension=propro.so\nextension=http.so" > /usr/local/etc/php/conf.d/docker-php-ext-http.ini \
&& rm -rf /usr/local/etc/php/conf.d/docker-php-ext-raphf.ini \
&& rm -rf /usr/local/etc/php/conf.d/docker-php-ext-propro.ini \
&& apk del .build-deps \
&& rm -rf /tmp/*
However when running composer update
, I get the following warning:
PHP Warning: PHP Startup: Unable to load dynamic library 'http.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/http.so (Error relocating /usr/local/lib/php/extensions/no-debug-non-zts-20170718/http.so: uidna_IDNToASCII: symbol not found), /usr/local/lib/php/extensions/no-debug-non-zts-20170718/http.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20170718/http.so.so: No such file or directory)) in Unknown on line 0
After which, the composer update
command fails:
The requested PHP extension ext-http * is missing from your system. Install or enable PHP's http extension.
The http.so.so
part of the warning gives me pause, making me think the file is being looked for in an incorrect location.
My reference is the following Dockerfile: https://hub.docker.com/r/realpaul/docker-php/dockerfile
Can someone please help me debug this issue? Thank you!
回答1:
A part of that error message reads:
http.so: uidna_IDNToASCII: symbol not found
According to PECL_HTTP is installed, but does not work, this error message points to iconv.so
not being available. Please try to enable that also through echo'ing to /usr/local/etc/php/conf.d/docker-php-ext-http.ini
.
Additionally, if you assume that http.so
is not placed at the position PHP is expecting, you should try to start a bash in your running container to see whether that file is there or not. But as that file throws an error, you can assume it's there
来源:https://stackoverflow.com/questions/60108096/php-http-extension-on-docker-alpine-image