Ing. Luca Stucchi
Ing. Luca Stucchi

Reputation: 3277

Problem adding Memcached support in Docker for PHP8.1 using bookworm

I have a Dockerfile relying on PHP:8.1-apache, running since months.

Once PHP:8.1-apache started to use Debian bookworm, the memcached client started to give an error while building the image.

The Dockerfile rows involved are

FROM php:8.1-apache

...

RUN apt-get update --fix-missing -q \
    && apt-get install -y curl mcrypt gnupg build-essential software-properties-common wget vim zip unzip libxml2-dev libz-dev libpng-dev libmemcached-dev \
    && pecl install memcached \
    && docker-php-ext-enable memcached \

...

The error at image build time is:

checking for libmemcached location... configure: error: memcached support requires libmemcached. Use --with-libmemcached-dir=<DIR> to specify the prefix where libmemcached headers and library are located
ERROR: `/tmp/pear/temp/memcached/configure --with-php-config=/usr/local/bin/php-config --with-libmemcached-dir=no --with-zlib-dir=no --with-system-fastlz=no --enable-memcached-igbinary=no --enable-memcached-msgpack=no --enable-memcached-json=no --enable-memcached-protocol=no --enable-memcached-sasl=yes --enable-memcached-session=yes' failed

Pinning the oldstable version solves the problem,

FROM php:8.1-apache-bullseye

And that clearly indicates that the issue is caused by the switch to new Debian Version.

What could be done to use bookworm and continue to use the same libraries and process ?

Upvotes: 5

Views: 4758

Answers (2)

Wireblue
Wireblue

Reputation: 1509

Ensure these libraries are installed (in particular, libssl-dev):

RUN apt install -y libmemcached-dev zlib1g-dev libssl-dev

Credit to AKorezin: https://github.com/php-memcached-dev/php-memcached/issues/541#issuecomment-1624041385

Then you can follow the usual PECL install process:

RUN yes '' | pecl install -f memcached-3.2.0 \
  && docker-php-ext-enable memcached

Upvotes: 15

Alez
Alez

Reputation: 2689

Add this two missing libraries in the Dockerfile:

RUN apt-get install -y libmemcached-dev libmemcached11

Upvotes: 0

Related Questions