PHPRedis installation on DirectAdmin

PHPRedis with IGBinary is a powerful tool to increase your redis connections from PHP. Instead of using libraries like predis, you can install PHPRedis which is a C library. This dramatically improves the performance when using Redis with PHP. We’ll show you how to do the PHPRedis installation on DirectAdmin!

This tutorial is written for RHEL/CentOS/RockyLinux/AlmaLinux and other distros based on RHEL.

Install Redis with DNF

If you haven’t already installed Redis, you can do this easily with DNF:

dnf install redis
systemctl enable --now redis.service
systemctl start redis.service
chown:chown redis:redis /etc/redis.conf

The next step is to install the PHPRedis C library, with IGBinary as serialiser.

Install IGBinary

Download the latest release (tar.gz) from: https://github.com/igbinary/igbinary/releases

  • Download latest release for example in /root/php_ext/igbinary
tar -xzf *latest_release.tar.gz*
cd *latest_release.tar.gz*
/usr/local/php80/bin/phpize80
./configure CFLAGS="-O2 -g" --enable-igbinary
make
make test
make install

Install PHPRedis

https://github.com/phpredis/phpredis/releases

  • Download latest release for example in /root/php_ext/phpredis
tar -xzf *latest_release.tar.gz*
cd *latest_release*.tar.gz
/usr/local/php80/bin/phpize80
./configure --enable-redis-igbinary --with-php-config=/usr/local/php80/bin/php-config80
make
make install

Add extensions to PHP config

cd /usr/local/php80/lib/php.conf.d
touch 20-custom.ini

If you use another PHP version, change it accordingly.

In this file, add:

extension=igbinary.so
extension=redis.so

And finally reload/restart php-fpm. Verify with:

php --ri redis

or

php -m

PHPRedis DirectAdmin Installation Check

If you see redis and igbinary in the list you have successfully installed the PHPRedis C extension with IGbinary as serialiser to your PHP installation!