Search code examples
phpphpredisubuntu-24.04

Can't install php7.1-redis on Ubuntu 24.04 (and some other extensions)


I am newbee here, sorry if the question is stupid I'm trying to install php7.1-redis on Ubuntu 24.04, but I'm getting the following errors:

E: Unable to locate package php7.1-redis
E: Couldn't find any package by glob 'php7.1-redis'
E: Couldn't find any package by regex 'php7.1-redis'

I'm using a repository ppa:ondrej/php Is there any way I can install this extension differently? Or do I need to wait for the repository to be updated?

I wanted to use other repositories, but I am inexperienced in the UNIX world and did not find the right repositories... I can install latest versions, but I need 7.1


Solution

  • ppa:ondrej/php does not provide the php7.1-redis package for ubuntu:24.04.

    You can install the redis extension with pecl.

    However, you need to install the php7.1-xml, php7.1-zip as prerequisites for pecl.

    Following are instructions to build a Docker image with redis support for php.

    FROM ubuntu:24.04
    
    RUN apt update && \
        apt -y install software-properties-common \
        && apt clean
    RUN LC_ALL=C.UTF-8 apt-add-repository ppa:ondrej/php \
        && apt -y install php7.1 php7.1-dev php7.1-xml php7.1-zip \
        && apt clean \
        # https://pear.php.net/manual/en/installation.getting.php
        && curl -O http://pear.php.net/go-pear.phar \
        && php go-pear.phar
    
    RUN pecl install redis-5.3.7