SmrutiRanjan
SmrutiRanjan

Reputation: 93

Php7 Redis Client on Alpine OS

I crafted a docker image using alpine 3.5 as base Image. I want my php apllication running inside container to communicate with a redis server.But I don't find any php7-redis client in Alpine.

Is there a workway around it ?I tried to use pecl to install redis but there is no pecl package in alpine.I tried with pear but pear doesn't have redis package. Any thoughts on this issue ?

Upvotes: 4

Views: 3192

Answers (3)

Ankit Mehta
Ankit Mehta

Reputation: 273

You can find your solution here https://pkgs.alpinelinux.org/package/edge/community/x86_64/php7-redis

Upvotes: 2

Paul
Paul

Reputation: 141819

For versions of Alpine prior to 3.6, such as the current official PHP Alpine image (Alpine 3.4), you need to build the extension from source. There are a few dependencies you also need to do that: autoconf, git, gcc/g++, and make. As an example, this is a complete Dockerfile for the latest stable release of PHP built on Alpine with the redis extension for php7 installed and enabled:

FROM php:alpine

RUN apk add --no-cache autoconf git g++ make

RUN \
  git clone https://github.com/phpredis/phpredis.git && \
  cd phpredis && \
  git checkout php7 && \
  phpize && \
  ./configure && \
  make && make install && \
  docker-php-ext-enable redis

If you want a smaller image you can remove the phpredis directory and the deps that were needed to clone and build it afterward. If you're not using an official PHP image then you will need to replace docker-php-ext-enable redis with a couple of commands to move the redis.so where you need it and add the extension=redis.so line to your PHP config.

Upvotes: 5

Jakub Jirutka
Jakub Jirutka

Reputation: 10817

php7-redis is in v3.6 (released yesterday) and edge (rolling/unstable), as you can easily find yourself on pkgs.alpinelinux.org.

pecl is currently provided by package php7-pear.

Upvotes: 2

Related Questions