Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save djsipe/30d971272c4a604078d813ffb1d0b4a6 to your computer and use it in GitHub Desktop.
Save djsipe/30d971272c4a604078d813ffb1d0b4a6 to your computer and use it in GitHub Desktop.

Assuming you are using the official PHP Docker image...

# ---------------------------------------------------------------
# PHP Extension: Gearman
# Download Gearman PECL extension for Gearman supporting PHP 7
RUN apt-get -y --allow-unauthenticated install \
    libgearman-dev
RUN cd /tmp \
    && git clone https://github.com/wcgallego/pecl-gearman.git \
    && cd pecl-gearman \
    && git checkout gearman-2.0.3 \
    && phpize \
    && ./configure \
    && make -j$(nproc) \
    && make install \
    && rm -r /tmp/pecl-gearman \
    && docker-php-ext-enable gearman
@williamwa
Copy link

I updated this one a little:

RUN apt-get -y --allow-unauthenticated install libgearman-dev wget unzip \
    && cd /tmp \
    && wget https://github.com/wcgallego/pecl-gearman/archive/gearman-2.0.3.zip \
    && unzip gearman-2.0.3.zip \
    && mv pecl-gearman-gearman-2.0.3 pecl-gearman \
    && cd pecl-gearman \
    && phpize \
    && ./configure \
    && make -j$(nproc) \
    && make install \
    && cd / \
    && rm /tmp/gearman-2.0.3.zip \
    && rm -r /tmp/pecl-gearman \
    && docker-php-ext-enable gearman

@comm1x
Copy link

comm1x commented Feb 11, 2018

@williamwa Thanks!

@nfrigus
Copy link

nfrigus commented Apr 12, 2018

And if anyone interested, here's some shorter version without extra dependencies (e.g. wget, unzip) and with fewer FS-operations:

ENV GEARMAN_VERSION=2.0.3
RUN set -xe \
    ; apt-get -y install libgearman-dev \
    ; TMPDIR=$(mktemp -d) \
    ; cd $TMPDIR \
    ; curl -L https://github.com/wcgallego/pecl-gearman/archive/gearman-${GEARMAN_VERSION}.tar.gz \
    | tar xzv --strip 1 \
    ; phpize \
    ; ./configure \
    ; make -j$(nproc) \
    ; make install \
    ; cd - \
    ; rm -r $TMPDIR \
    ; docker-php-ext-enable gearman

Note the version can be picked from available releases.

@ja-weber
Copy link

For php 7.4 this is not working. Only for php 7.3. Has someone handled to install it on php 7.4?

@mlocati
Copy link

mlocati commented Jan 17, 2021

I recently updated my install-php-extensions script; it now supports installing the gearman PHP extension (as well as 92 other PHP extensions) with a single line:

install-php-extensions gearman

More info here: https://github.com/mlocati/docker-php-extension-installer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment