Closed polds closed 9 years ago
@polds I think you want to use "Dockerfile 2", but you need to install libz-dev
to make configure
happy.
Actually, nevermind... I thought you were using docker-php-ext-install
:confused:
You need something like this:
FROM php:5.5.29-apache
RUN apt-get update && apt-get install -y libz-dev libmemcached-dev
RUN pecl install memcached
@md5 thank you that was indeed it with the following modification (for future readers):
FROM php:5.5.29-apache
RUN apt-get update && apt-get install -y libz-dev libmemcached-dev
RUN pecl install memcached
RUN echo extension=memcached.so >> /usr/local/etc/php/conf.d/memcached.ini
Thanks @polds.
That reminds me that @helderco once mentioned creating a docker-php-pecl-install
script: https://github.com/docker-library/php/issues/115#issuecomment-120720217
The smallest layer for the pecl install is probably the following:
RUN apt-get update \
&& apt-get install -y libmemcached11 libmemcachedutil2 build-essential libmemcached-dev libz-dev \
&& pecl install memcached \
&& echo extension=memcached.so >> /usr/local/etc/php/conf.d/memcached.ini \
&& apt-get remove -y build-essential libmemcached-dev libz-dev \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /tmp/pear
^ That worked as well.
Thanks @hairmare I was being lazy since I don't tend to be as aggressive with the sizes of "normal" images.
I think you'll also want a rm -rf /var/lib/apt/lists/*
in there as well since apt-get clean
doesn't clean as much as it could.
I failed to get memcached to work on PHP7. Finally managed to do so using the following lines, using the php7 branch and building from source:
# Memcached
RUN apt-get install -y libmemcached-dev \
&& cd /tmp \
&& git clone -b php7 https://github.com/php-memcached-dev/php-memcached.git \
&& cd php-memcached \
&& phpize \
&& ./configure \
&& make \
&& echo "extension=/tmp/php-memcached/modules/memcached.so" > /usr/local/etc/php/conf.d/memcached.ini
Is there any better way?
@roelvanduijnhoven for PHP7 ì'm doing this:
git clone https://github.com/php-memcached-dev/php-memcached /usr/src/php/ext/memcached \
&& cd /usr/src/php/ext/memcached && git checkout -b php7 origin/php7 \
&& docker-php-ext-configure memcached \
&& docker-php-ext-install memcached
Thanks @paolomainardi, looks a lot easier. I realise now how the bundled docker-php-ext.. scripts work.
@roelvanduijnhoven you're welcome
Thank you all. I further shortened https://github.com/docker-library/php/issues/132#issuecomment-170924782 a little bit. Now, I am using this config in my image for Drupal https://github.com/INsReady/php-fpm-for-cms/blob/master/7.0/Dockerfile#L11
With last version php:7.0-fpm stop working
Cloning into '/usr/src/php/ext/memcached'...
usage: /usr/local/bin/docker-php-ext-configure ext-name [configure flags]
ie: /usr/local/bin/docker-php-ext-configure gd --with-jpeg-dir=/usr/local/something
Possible values for ext-name:
bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json ldap mbstring mcrypt mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zip
``
@vitalyzhakov, I think that is related to #266.
Did anyone manage to fix this problem? I am reading through #266 but have no clue if and how I should solve this..
@roelvanduijnhoven ,
This code works for me under php 7.0.8-fpm
# install memcached
&& apt-get -y install libmemcached11 libmemcachedutil2 libmemcached-dev \
&& git clone --branch php7 https://github.com/php-memcached-dev/php-memcached \
&& cd php-memcached \
&& phpize \
&& ./configure \
&& make \
&& echo "extension=/var/www/html/php-memcached/modules/memcached.so" > /usr/local/etc/php/conf.d/memcached.ini
Thanks! :heart:
This may be obvious, but for someone (like me) it's not.
Notice that the above snippet puts the memcached library into /var/www/html/
. When you create a volume from a host directory and mount that into /var/www/html
, docker "overwrites" that path and your module "disappears".
So if you want to mount a volume into /var/www/html
, change the snippet to clone the repo into another directory and adjust the corresponding line that creates the php config file.
Something like this works for me:
RUN apt-get -y install libmemcached11 libmemcachedutil2 libmemcached-dev \
&& cd /usr/local/share \
&& git clone --branch php7 https://github.com/php-memcached-dev/php-memcached \
&& cd php-memcached \
&& phpize \
&& ./configure \
&& make \
&& echo "extension=/usr/local/share/php-memcached/modules/memcached.so" > /usr/local/etc/php/conf.d/memcached.ini
Please do it the right way: use the docker-php-*
scripts and cleanup afterwards.
The best practice should look something like this:
FROM php:7.0-fpm
RUN apt-get update \
&& buildDeps=" \
git \
libmemcached-dev \
zlib1g-dev \
" \
&& doNotUninstall=" \
libmemcached11 \
libmemcachedutil2 \
" \
&& apt-get install -y $buildDeps --no-install-recommends \
&& rm -r /var/lib/apt/lists/* \
\
&& docker-php-source extract \
&& git clone --branch php7 https://github.com/php-memcached-dev/php-memcached /usr/src/php/ext/memcached/ \
&& docker-php-ext-install memcached \
\
&& docker-php-source delete \
&& apt-mark manual $doNotUninstall \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps
This way you use docker-php-source
, don't have to create an ini
file, call phpize
and make
yourself and most important this way you remove not needed -dev
packages and all their dependencies (except for runtime dependencies in $doNotUninstall
) to save disk-space.
@adminblogger nice! Thx!
If your favor... Tell me pls... Where can i find runtime dependencies for another extensional?
I can mark to delete git, zlib1g-dev
, but someone once?
Using on install
FROM php:7.0.11-fpm
RUN apt-get update && apt-get install -y \
git \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
zlib1g-dev \
libicu-dev \
libpq-dev \
libmagickwand-dev \
&& apt-get clean \
&& docker-php-ext-install -j$(nproc) pdo_mysql pdo_pgsql \
&& docker-php-ext-configure intl \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) intl gd \
&& pecl install imagick \
&& docker-php-ext-enable imagick
For anyone who finds this because their Dockerfile has begun to fail while trying "pecl install memcached" (with the error "pecl/memcached requires PHP (version >= 7.0.0), installed version is [5.6.something]", on 02/08/17 the pecl memcached package version 3.0 was released, requiring php 7.0 or higher.
To continue using memcached with php 5.6.x, update your Dockerfile to use version 2.2.0 of the memcached package:
pecl install memcached-2.2.0
instead of
pecl install memcached
The relevant section of my Dockerfile, as a result, is:
RUN apt-get -y install libz-dev libmemcached-dev libmemcached11 libmemcachedutil2 build-essential \
&& pecl install memcached-2.2.0 \
&& echo extension=memcached.so >> /usr/local/etc/php/conf.d/memcached.ini \
&& apt-get remove -y build-essential libmemcached-dev libz-dev \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /tmp/pear
Wondering if anyone has gotten memcached (not memcache) to work? Trying to build in
php:5.5.29-apache
to get the php memcached module installed. I have tried the following to no avail. Any help is greatly appreciated.Dockerfile 1
Notes:
Dockerfile 2
Notes:
Dockerfile 3
Notes: