Articles

How to Install the PHP Redis Extension

To install a PECL extension for multiple PHP versions, repeat the PECL extension installation for each PHP version.
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. Read more about installing the Redis server.

Installing the Redis Extension on PHP 7.X

In the examples shown, replace "7.X" with your app's PHP version (for example, "7.0").

To install the PHP Redis extension on PHP 7.0, PHP 7.1, or PHP 7.2, SSH in to your server as root and run the following commands:

sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo pecl7.X-sp install redis

When prompted with:

enable igbinary serializer support? [no] :

press Enter to accept the default.

Once installed, create a configuration file for the extension and restart PHP by running the following commands as root:

sudo bash -c "echo extension=redis.so > /etc/php7.X-sp/conf.d/redis.ini"
sudo service php7.X-fpm-sp restart

Installing the Redis Extension on PHP 5.X

The most recent version of the Redis extension can only be installed on PHP 7.0 and above. If you need to use the Redis extension on PHP 5.4, 5.5, or 5.6, you must run Version 2.2.8.

In the examples shown, replace "5.X" with your app's PHP version (for example, "5.4").

To install this extension, run the following commands as your server's root user:

sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo pecl5.X-sp install redis-2.2.8

Once installed, create a configuration file for the extension and restart PHP by running the following commands as root:

sudo bash -c "echo extension=redis.so > /etc/php5.X-sp/conf.d/redis.ini"
sudo service php5.X-fpm-sp restart

Using the PHP Redis Extension

See the documentation for the PHP Redis extension for usage information.


Last updated: August 31, 2017