Redis PHP extension for Plesk PHP 8

To install the PHP Redis extension under Plesk Obsidian for PHP 8, first log in to the Plesk server via SSH. Then execute the following commands:


Preparation

Additional packages must be installed to install the Redis extension:


apt update
apt install plesk-php80-dev plesk-php81-dev plesk-php82-dev plesk-php83-dev zlib1g-dev gcc make


Before installing PHP extensions, a server snapshot should be created so that you can undo the installation with just a few clicks in the event of an error. Learn more →



Installation of the Redis extension

Carry out the installation using the pecl command:

/opt/plesk/php/8.0/bin/pecl install redis
/opt/plesk/php/8.1/bin/pecl install redis
/opt/plesk/php/8.2/bin/pecl install redis
/opt/plesk/php/8.3/bin/pecl install redis


After successful installation, the extension must be added to the PHP configuration:


echo "extension=redis.so" > /opt/plesk/php/8.0/etc/php.d/redis.ini
echo "extension=redis.so" > /opt/plesk/php/8.1/etc/php.d/redis.ini
echo "extension=redis.so" > /opt/plesk/php/8.2/etc/php.d/redis.ini
echo "extension=redis.so" > /opt/plesk/php/8.3/etc/php.d/redis.ini


To enable the new configuration via the Plesk web interface, the PHP 8 handler must be reloaded:


plesk bin php_handler --reread


The PHP handler must then be restarted in order to use the Redis extension:


Warning: Restarting the PHP modules will terminate and restart all running PHP processes. If the installation is carried out on a production system, we recommend making this change at night.


# PHP 8.0
systemctl restart plesk-php80-fpm

# PHP 8.1
systemctl restart plesk-php81-fpm

# PHP 8.2
systemctl restart plesk-php82-fpm

# PHP 8.3
systemctl restart plesk-php83-fpm



Verify installation

After successful installation, check whether the variables of the Redis extension are available:


/opt/plesk/php/8.3/bin/php -i |grep redis

# Example output:
/opt/plesk/php/8.3/etc/php.d/redis.ini,
redis
redis.arrays.algorithm => no value => no value
redis.arrays.auth => no value => no value
redis.arrays.autorehash => 0 => 0
redis.arrays.connecttimeout => 0 => 0
redis.arrays.consistent => 0 => 0
redis.arrays.distributor => no value => no value
redis.arrays.functions => no value => no value
redis.arrays.hosts => no value => no value
redis.arrays.index => 0 => 0
redis.arrays.lazyconnect => 0 => 0
redis.arrays.names => no value => no value
redis.arrays.pconnect => 0 => 0
redis.arrays.previous => no value => no value
redis.arrays.readtimeout => 0 => 0
redis.arrays.retryinterval => 0 => 0
redis.clusters.auth => no value => no value
redis.clusters.cache_slots => 0 => 0
redis.clusters.persistent => 0 => 0
redis.clusters.read_timeout => 0 => 0
redis.clusters.seeds => no value => no value
redis.clusters.timeout => 0 => 0
redis.pconnect.connection_limit => 0 => 0
redis.pconnect.echo_check_liveness => 1 => 1
redis.pconnect.pool_pattern => no value => no value
redis.pconnect.pooling_enabled => 1 => 1
redis.session.lock_expire => 0 => 0
redis.session.lock_retries => 10 => 10
redis.session.lock_wait_time => 2000 => 2000
redis.session.locking_enabled => 0 => 0


The Redis extension can then be used via FPM (Apache / nginx) or via CLI.