How to install redis extension for php 7
Solution 1
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
Solution 2
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.
Solution 3
I found a repository from ubuntu:
sudo apt-get install php-redis
- Restart apache after installation.
Solution 4
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
Solution 5
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
Related videos on Youtube
Prashant G Patil
Updated on July 09, 2022Comments
-
Prashant G Patil almost 2 years
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.
-
colidyre about 6 yearsI 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
. Thensudo service php7.0-fpm restart && sudo apache2ctl restart
was successful. -
Muhammad Usama over 4 yearsIf 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
. Thensudo service php7.0-fpm restart & sudo service nginx restart
-
rohitcoder about 4 yearsNot working! I am using php 7.2.7 and last available is for 7.1.8
-
Jeremy about 4 years@rohitcoder Try this github.com/jrquick17/php-extension-library
-
Hugo almost 2 yearsThis actually works - I'm using php:7.3.33-apache as base for my docker image