How to install redis extension for php 7
Asked Answered
M

10

37

Referred this link https://anton.logvinenko.name/en/blog/how-to-install-redis-and-redis-php-client.html

And done following steps

PhpRedis for PHP 7 (Skip it if you have different PHP version)

Install required package

apt-get install php7.0-dev

Download PhpRedis

cd /tmp
wget https://github.com/phpredis/phpredis/archive/php7.zip -O phpredis.zip

But, https://github.com/phpredis/phpredis/archive/php7.zip file not found for installation.

Mammalogy answered 26/10, 2017 at 13:23 Comment(0)
T
37

Try to use this url https://github.com/phpredis/phpredis/archive/5.2.2.zip

wget https://github.com/phpredis/phpredis/archive/5.2.2.zip -O phpredis.zip

Or use this command:

sudo apt-get install php-redis
Two answered 26/10, 2017 at 13:46 Comment(1)
with the command is it possible to specify the phpredis redis version ?Impervious
M
29

Yesterday, I installed Redis on my Vagrant box (/etc/php/7.0):

  • sudo pecl install redis
  • sudo service php7.0-fpm restart

(optional: run php -m for listing the php modules).

Now, you can use the Redis class in your php code.

Malapropos answered 26/10, 2017 at 13:39 Comment(2)
I had to do some extra work: after sudo pecl install redis: echo "extension=redis.so" > /etc/php/7.0/mods-available/redis.ini && ln -sf /etc/php/7.0/mods-available/redis.ini /etc/php/7.0/fpm/conf.d/20-redis.ini && ln -sf /etc/php/7.0/mods-available/redis.ini /etc/php/7.0/cli/conf.d/20-redis.ini. Then sudo service php7.0-fpm restart && sudo apache2ctl restart was successful.Rhys
If you have PHP 7.3 with Nginx: then sudo pecl install redis: echo "extension=redis.so" > /etc/php/7.3/mods-available/redis.ini && ln -sf /etc/php/7.3/mods-available/redis.ini /etc/php/7.3/fpm/conf.d/20-redis.ini && ln -sf /etc/php/7.3/mods-available/redis.ini /etc/php/7.3/cli/conf.d/20-redis.ini. Then sudo service php7.0-fpm restart & sudo service nginx restartCapital
X
20

I found a [repository][1] from ubuntu:

sudo apt-get install php-redis
Xylon answered 4/3, 2019 at 6:0 Comment(2)
the packges not availableImpervious
@Impervious packages.ubuntu.com/focal/php-redisXylon
E
8

If you happen to be in a docker container just:

pecl install redis
docker-php-ext-enable redis

will do in most cases.

Educe answered 24/3, 2022 at 18:38 Comment(1)
This actually works - I'm using php:7.3.33-apache as base for my docker imageDelaney
E
6

For people who are using MAMP, you want to execute the pecl installer from withing MAMP. This follows the installment from https://github.com/phpredis/phpredis/blob/develop/INSTALL.markdown.

/Applications/MAMP/bin/php/php7.3.9/bin/pecl install redis

Change the php version to yours.

After successfully installing, will probably say something like this:

configuration option "php_ini" is not set to php.ini location
You should add "extension=redis.so" to php.ini

So you need to go to your php.ini, and add extension=redis.so.

For me, this folder is: /Applications/MAMP/bin/php/php7.3.9/conf/php.ini

After restarting your MAMP, you will see a redis module on this page (ports might not be the same): http://localhost:8888/MAMP/index.php?language=English&page=phpinfo

Emanuelemanuela answered 28/6, 2020 at 21:23 Comment(0)
E
5

I just ran the command below for Cent os 7

yum install php-redis

Resolved my issue and i added the config in php.ini manualy

You should add "extension=redis.so" to php.ini

Employee answered 16/3, 2020 at 19:27 Comment(0)
S
3

For Debian-based Linux distros you need a php-dev and pkg-php-tools packages for building native PHP extension from phpredis source code:

sudo apt update && \
    sudo apt install php-dev pkg-php-tools --yes && \
    sudo pecl channel-update pecl.php.net && \
    sudo pecl install redis
Skinner answered 19/1, 2021 at 15:13 Comment(0)
R
3

Install redis with a command:

sudo apt-get install php7.0-redis
Rosalynrosalynd answered 8/2, 2022 at 20:5 Comment(0)
S
1

This GitHub is a great resource for MAMP users.

For Mac Users:

  1. Download redis.so from the appropriate subdirectory of the repo based on major and minor version number X.Y (following semver).
  2. Move the file to /Applications/MAMP/bin/php/phpX.Y.X/lib/php/extensions/no-debug-non-zts-xxxxxxxx
  3. Add extension=redis.so to the end of php.ini

Updated resource above, previously listed this

Seiler answered 23/3, 2019 at 1:26 Comment(2)
Not working! I am using php 7.2.7 and last available is for 7.1.8Autoerotic
@Autoerotic Try this github.com/jrquick17/php-extension-librarySeiler
G
0

Me using PHP8 with Nginx an this below command work for me.

wget https://github.com/phpredis/phpredis/archive/refs/tags/5.3.7.tar.gz
tar xf 5.3.7.tar.gz
cd phpredis-5.3.7
phpize
./configure
make
make install
echo “extension=redis.so” >> /etc/php.ini

To verify that phpredis was actived you can check in your php configuration like this.

php -i | grep redis

And dont remember to restart your PHP-FPM

Geordie answered 21/5, 2023 at 2:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.