To install the PHP Redis extension on PHP 8.0, 8.1, 8.2, or 8.3, SSH in to your server as root and run the following commands:
sudo apt-get -y install gcc make autoconf libc-dev pkg-config yes '' | sudo pecl8.Y-sp install redis
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/php8.X-sp/conf.d/redis.ini" sudo service php8.X-fpm-sp restart
To install the PHP Redis extension on PHP 7.0, 7.1, 7.2, 7.3, or 7.4, SSH in to your server as root and run the following commands:
sudo apt-get -y install gcc make autoconf libc-dev pkg-config yes '' | sudo pecl7.X-sp install redis
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
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.
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
See the documentation for the PHP Redis extension for usage information.
To uninstall this extension, as root run the commands:
sudo rm /etc/phpX.Y-sp/conf.d/redis.ini sudo peclX.Y-sp uninstall redis
Next, restart PHP-FPM with the command:
sudo service phpX.Y-fpm-sp restart