Redis is an open source, in-memory data structure store, mainly used as cache system. We can improve the speed of websites using Redis cache server. Popular website platform like WordPress has a plugin named “Redis-object-cache” to integrate with Redis cache server. So in this example through plesk we install Redis cache server and integrate with a WordPress website which is hosted on a Plesk server itself.

As of now Redis Server is currently not supported in Plesk panel. Which means we can’t directly install Redis server as a plugin on Plesk portal. We need to do manually. So in this blog post we implement the Redis server using different methods.

Running Redis with a docker container

  1. Login into Plesk
  2. Install Docker extension by clicking extension from Plesk panel
  3. After that go the Docker extension tab and Found Redis image in the catalog and click run on the required image.
  4. There will different Redis docket images will show up. I choose redis:latest itself.
  5. Unchecked “Automatic port mapping ” and give the port as 6379 as external too.

We can confirm if its running using below command can see port 6379 is listening.

Copy to Clipboard

We can also create the Redis container directly from the command line.

Copy to Clipboard

Now in order to make sure Redis is working, we can run command “redis-cli ping”. If you get result “PONG”, that shows Redis is working. So lets see how it can be accomplished in case of Redis docket image.

Copy to Clipboard

How to install Redis server using yum command

Follow this method if we are not installing the Redis server using docker imange.

install Redis server using yum command

Copy to Clipboard

If you are having debian/Ubuntu server use below command. Normally it will install the Redis server.

Copy to Clipboard

Now lets install Redis PHP extension, using following command.

As of now we installed Redis cache server in the server and now we are proceeding with the installation of Redis php extension.

Copy to Clipboard

Warning: “continue” targeting switch is equivalent to “break”. Did you mean to use “continue 2”? in PEAR/PackageFile/v2/Validator.php on line 1933
PHP Warning: “continue” targeting switch is equivalent to “break”. Did you mean to use “continue 2”? in /opt/plesk/php/7.4/share/pear/PEAR/PackageFile/v2/Validator.php on line 1933
29 source files, building
running: phpize
sh: phpize: command not found
ERROR: `phpize’ failed

In my case, I got above error, So I have installed devel package using below command.

Copy to Clipboard

http://autoinstall.plesk.com/PHP74_17/dist-rpm-CentOS-7-x86_64/extra/plesk-php74-devel-7.4.7-1centos.7.200616.1427.x86_64.rpm: [Errno 14] HTTP Error 404 – Not Found ] 0.0 B/s | 0 B –:–:– ETA
Trying other mirror.

if you got error like below. Open file /etc/yum.conf and set “gpgcheck” value to “0” and run yum update

And we can see the Redis php extension rpm package is installing from Plesk repository.  So in short we don’t need to install the Redis php extension in a Plesk server because its included by default. We only need to perform the install if its missing from the server. We can verify the extension using below command.

Copy to Clipboard

If its still not enabled try to issue below command

Copy to Clipboard

Now if you still not succeeded with the yum install try the pecl install of Redis.

Copy to Clipboard

We should now be able to see the extension in Tools & Settings > PHP Settings > *any PHP 7.4 handler*

Install Redis-object-cache in WordPress

  1. Install plugin named Redis Object Cache plugin
  2. Go the Wp-Admin area of wordpress and click the “Object Cache” button.
  3. After that it will usually look like below.

4. Edit our wp-config.php and at the end of the file add the following lines. Note that string can be anything you want, as long as it’s unique.

Copy to Clipboard

Then, you can enable object-cache in the plugin settings page :

In order to test whether the WordPress install is cached by WordPress, issue  “redis-cli monitor” command over SSH and click any link in the wp-admin area. The result should be like below. It means we can see log entries appear and that conclude WordPress is communicating with Redis.

If you used docker redis image, first connect to the docker command line and then use the “redis-cli monitor” command.

Copy to Clipboard

This concludes a normal install of Redis Cache. Let me know your thoughts in the comment box. Hope you enjoyed this blog article.  We will hopefully come up with a new blog article soon.