Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
PHP use Redis
installation
Before you start using Redis in PHP, we need to ensure that services and PHP redis redis driver has been installed on your machine and normal use PHP. Let's install PHP redis drive: Download address: https://github.com/phpredis/phpredis/releases .
PHP extensions installed redis
The following needs to be done in the downloadable phpredis directory:
$ wget https://github.com/phpredis/phpredis/archive/3.1.4.tar.gz
$ cd phpredis-3.1.4 # 进入 phpredis 目录
$ /usr/local/php/bin/phpize # php安装后的路径
$ ./configure --with-php-config=/usr/local/php/bin/php-config
$ make && make install
Modify the php.ini file
vi /usr/local/php/lib/php.ini
Add the following:
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20090626"
extension=redis.so
After installation, restart php-fpm or apache. View phpinfo information, you can see redis extension.