Php: Can't install an external lib

Created on 15 Jul 2016  路  9Comments  路  Source: docker-library/php

Hello,
I try to install an external lib using php:5.6-apache image.
I use this in my dockerfile to install phpredis lib

RUN curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/3.0.0.tar.gz \
    && tar xfz /tmp/redis.tar.gz \
    && rm -r /tmp/redis.tar.gz \
    && mv phpredis-3.0.0 /usr/src/php/ext/redis \
    && docker-php-ext-install redis

But i get this error :

mv: cannot move 'phpredis-3.0.0' to '/usr/src/php/ext/redis': No such file or directory

Can you please help me on this
Thx :)

Most helpful comment

This is what I did:

RUN docker-php-source extract \
    && curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/2.2.8.tar.gz \
    && tar xfz /tmp/redis.tar.gz \
    && rm -r /tmp/redis.tar.gz \
    && mv phpredis-2.2.8 /usr/src/php/ext/redis \
    && sed -i '$ a redis' /usr/src/php-available-exts \
    && docker-php-ext-install redis \
    && docker-php-source delete

By the way,3.0.0 is only for php7,you need 2.2.8. https://github.com/phpredis/phpredis/issues/884

All 9 comments

Same issue here with php:5.5-apache

Noticed it yesterday.
Seems that 'redis' is missing from php-available-exts... If I add it manually docker-php-ext-install redis works.

@fprezat ok so what you need to do is more something like:

RUN docker-php-source extract \
    && curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/3.0.0.tar.gz \
    && tar xfz /tmp/redis.tar.gz \
    && rm -r /tmp/redis.tar.gz \
    && mv phpredis-3.0.0 /usr/src/php/ext/redis \
    && docker-php-ext-install redis

This is what I did:

RUN docker-php-source extract \
    && curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/2.2.8.tar.gz \
    && tar xfz /tmp/redis.tar.gz \
    && rm -r /tmp/redis.tar.gz \
    && mv phpredis-2.2.8 /usr/src/php/ext/redis \
    && sed -i '$ a redis' /usr/src/php-available-exts \
    && docker-php-ext-install redis \
    && docker-php-source delete

By the way,3.0.0 is only for php7,you need 2.2.8. https://github.com/phpredis/phpredis/issues/884

Hello
@shouze Your solution works great :)
@airycanon ok thx for the warning, i will use 2.2.8
@mitchhh22 thx for the help

@fprezat so maybe you can close this issue then?
It's mainly because of https://github.com/docker-library/php/pull/256 which reduce the docker image size so the benefits worth the tiny needed changes for the installation of some custom/not bundled within php extensions.

You can still use pecl for this, but the important thing is to extract/delete the source.

RUN docker-php-source extract && \
    pecl install xdebug redis && \
    docker-php-ext-enable xdebug redis && \
    docker-php-source delete

Using the php:7-apache image, I downloaded from github (listed many times above) into /usr/src/php/ext/redis, except that I used the php7 branch, i.e. https://github.com/phpredis/phpredis/archive/php7.zip, instead of specifying 3.0.0 as @airycanon commented

today building my image failed with /usr/src/php/ext no such file or directory (following shouze's suggestion). last time i had to rebuild, it worked flawlessly. i guess there were some changes in the fpm base image, and adding 'mkdir -p /usr/src/php/ext' fixed that for me. just in case somebody runs into the same problem.

@airycanon I get this error:mv: cannot move 'phpredis-2.2.7' to '/usr/src/php/ext/redis': No such file or directory I'm using FROM php:5.6-fpm. I tried mkdir -p /usr/src/php/ext/redis \ but obviously fails again:
Cannot find config.m4. Make sure that you run '/usr/local/bin/phpize' in the top level source directory of the module

Was this page helpful?
0 / 5 - 0 ratings