Php7 Redis Client on Alpine OS

丶灬走出姿态 提交于 2021-02-18 13:37:07

问题


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 ?


回答1:


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




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/44177724/php7-redis-client-on-alpine-os

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!