Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install redis extension for php 7

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.

like image 313
Prashant G Patil Avatar asked Oct 26 '17 13:10

Prashant G Patil


People also ask

What is php Redis extension?

This PHP extension provides client access to the Redis server. It is not Redis itself. Redis is a server that provides a key/value store. When you install the Redis PHP extension, it will allow PHP to communicate with a Redis server.

How connect PHP to Redis?

php //Connecting to Redis server on localhost $redis = new Redis(); $redis->connect('127.0. 0.1', 6379); echo "Connection to server sucessfully"; //set the data in redis string $redis->set("tutorial-name", "Redis tutorial"); // Get the stored data and print it echo "Stored string in redis:: " .


9 Answers

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
like image 167
Iurii Drozdov Avatar answered Oct 05 '22 22:10

Iurii Drozdov


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.

like image 43
schellingerht Avatar answered Oct 06 '22 00:10

schellingerht


I found a repository from ubuntu:

sudo apt-get install php-redis
  • Restart apache after installation.
like image 33
Amir Fo Avatar answered Oct 05 '22 23:10

Amir Fo


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

like image 45
Farzie Karamat Avatar answered Oct 05 '22 23:10

Farzie Karamat


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

like image 22
Danoctum Avatar answered Oct 05 '22 23:10

Danoctum


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
like image 27
Dunaevsky Maxim Avatar answered Oct 05 '22 23:10

Dunaevsky Maxim


If you happen to be in a docker container just:

pecl install redis
docker-php-ext-enable redis

will do in most cases.

like image 27
Victor Timoftii Avatar answered Oct 05 '22 23:10

Victor Timoftii


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

like image 41
Jeremy Avatar answered Oct 05 '22 23:10

Jeremy


Install redis with a command:

sudo apt-get install php7.0-redis
like image 22
Kakarotto_94 Avatar answered Oct 05 '22 22:10

Kakarotto_94