The easiest way to install the PHPRedis extension is through the package manager. Ploi uses the Sury PHP repository, which ships a prebuilt Redis extension for each PHP version. Login as the root user and run:
apt install -y php8.5-redis
systemctl restart php8.5-fpm.service
Replace 8.5 with your PHP version. Verify the extension is loaded with:
php -m | grep redis
Installing via PECL (fallback)
If a prebuilt package isn't available for your PHP version, you can compile the extension with PECL instead:
1. Install the build tools:
apt install -y php-pear php8.5-dev
2. Install the Redis extension:
printf "no\n" | pecl install redis
3. Enable it for both FPM and CLI:
echo "extension=redis.so" > /etc/php/8.5/mods-available/redis.ini
ln -sf /etc/php/8.5/mods-available/redis.ini /etc/php/8.5/fpm/conf.d/20-redis.ini
ln -sf /etc/php/8.5/mods-available/redis.ini /etc/php/8.5/cli/conf.d/20-redis.ini
4. Restart PHP-FPM:
systemctl restart php8.5-fpm.service
Again, replace 8.5 with the PHP version you use.