Install php7-gd in alpine

夙愿已清 提交于 2019-12-10 14:05:34

问题


This is my Dockerfile

FROM php:7.1-fpm-alpine
RUN docker-php-ext-install mysqli 
RUN echo "http://dl-4.alpinelinux.org/alpine/edge/community/" >>         /etc/apk/repositories &&
apk update && \
apk upgrade && \
apk add --update \
    php7-gd

mysqli is ok, but it does not load GD library.

I also find gd.so in alpine container, please check the image:

Please help


回答1:


You should not mix Alpine Linux 3.4, Alpine Linux edge and PHP compiled from source.

Solution 1

Use the official latest release of Alpine Linux

FROM alpine:3.5

and add

http://dl-cdn.alpinelinux.org/alpine/3.5/community

then install memcache using pecl (in php7-pear).

Solution 2

Use the docker-php-ext-install script to add gd

FROM php:7.1-fpm-alpine
RUN apk add --no-cache libpng libpng-dev && docker-php-ext-install gd && apk del libpng-dev

For more image support you can also apk add and del:

libjpeg-turbo-dev libwebp-dev zlib-dev libxpm-dev

I left the answer using the official Alpine Linux on top, since we should always try to use official docker repos. But currently the second solution is better.

The second solution was provided by ncopa at the Alpine Linux IRC channel. Thanks.



来源:https://stackoverflow.com/questions/42087734/install-php7-gd-in-alpine

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!