How to integrate Redis with WordPress on LSWS

Redis is an open source, in-memory data structure store, used as a database, cache and message broker. LSCache is the world's fastest full page caching. So it's useful for you to have both of them setup on your server. This guide can be used both with and without a control panel.

Install Redis daemon

For cPanel/Plesk/DirectAdmin and Native LSWS setup on CentOS 7:

  1. Add the EPEL repository:
    yum install epel-release 
  2. Install Redis:
    yum install redis
  3. Start Redis:
    systemctl start redis

Install Redis PHP extension

The phpredis extension provides an API for communicating with the Redis key-value store.

With cPanel EasyApache 4

  1. Installing the Redis PHP extension for all available versions of PHP (Copy and paste the entire block of text together - don't copy/paste line-by-line):
    for phpver in $(ls -1 /opt/cpanel/ |grep ea-php | sed 's/ea-php//g') ; do
    cd ~
    wget -O redis.tgz
    tar -xvf redis.tgz
    cd ~/redis* || exit
    ./configure --with-php-config=/opt/cpanel/ea-php"$phpver"/root/usr/bin/php-config
    make && make install
    echo '' > /opt/cpanel/ea-php"$phpver"/root/etc/php.d/redis.ini
    rm -rf ~/redis*
  2. Check Redis:
    for phpver in $(ls -1 /opt/cpanel/ |grep php | sed 's/ea-php//g') ; do
    echo "PHP $phpver" ; /opt/cpanel/ea-php$phpver/root/usr/bin/php -i |grep "Redis Support"

    Output should be:

    PHP 55
    Redis Support => enabled
    PHP 56
    Redis Support => enabled
    PHP 70
    Redis Support => enabled 
    PHP 71
    Redis Support => enabled 


With Plesk

General Plesk support php-redis extention

If your Plesk version not support php-redis by default, please try compile Follow Here

With DirectAdmin

DirecAdmin custombuild 2 will install phpxx to /usr/local/phpxx, you can go to the version you want (such as php73) to build php-redis through pecl:

cd /usr/local/php73/bin
./pecl install igbinary igbinary-devel
./pecl install redis

Check the path of extensions.

ll /usr/local/php73/lib/php/extensions/
drwxr-xr-x 2 root root 76 Mar  3 14:05 no-debug-non-zts-20180731

Then add both and to a newly created 10-directadmin.ini

vi /usr/local/php73/lib/php.conf.d/10-directadmin.ini


Restart lsphp to make the change effective:

killall -9 lsphp

Without control panel

  1. Add the litespeed repository:
    rpm -ivh
  2. List the litespeed Redis PHP extension
    yum list | awk '/lsphp/&&/redis/'
  3. Install PHP (substitute the your lsphp version if it is different):
    yum -y install lsphp71-pecl-redis

Verify the Installation

  1. Verify that Redis is running with redis-cli:
    redis-cli ping

    If Redis is running, it will return:

  2. Verify by using LiteSpeed default PHP info page http://Server_IP:8088/phpinfo.php:

Try the redis-benchmark utility

  1. A typical example would be:
     redis-benchmark -q -n 100000 


    PING_INLINE: 31826.86 requests per second
    PING_BULK: 31595.58 requests per second
    SET: 33568.31 requests per second
    GET: 31908.10 requests per second
    INCR: 32647.73 requests per second
    LPUSH: 31220.73 requests per second
    RPUSH: 31565.66 requests per second
    LPOP: 31555.70 requests per second
  2. If you want to run one million SET operations, using a random key for every operation out of 100k possible keys, you can use the following command line:
    redis-cli flushall 
    redis-benchmark -t set -r 100000 -n 1000000


    ====== SET ======
      1000000 requests completed in 32.43 seconds
      50 parallel clients
      3 bytes payload
      keep alive: 1
    99.98% <= 10 milliseconds
    99.99% <= 11 milliseconds
    99.99% <= 12 milliseconds
    100.00% <= 17 milliseconds
    30833.75 requests per second

Note: For more redis benchmark information, please refer to this

Integrate WordPress with Redis

Other Settings

  • If you want to setup Master-Slave Replication, you may need to enable firewall for port 6379
    firewall-cmd --permanent --zone=public --add-port=6379/tcp
    firewall-cmd --reload 
  • To automatically start Redis on boot:
    systemctl enable redis
  • For disk persistence, you can set /etc/redis.conf:
    • appendonly yes
    • appendfsync everysec
  • For more Redis Security information please refer to this
  • Admin
  • Last modified: 2020/03/03 14:22
  • by Jackson Zhang