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
- Login into Plesk
- Install Docker extension by clicking extension from Plesk panel
- After that go the Docker extension tab and Found Redis image in the catalog and click run on the required image.
- There will different Redis docket images will show up. I choose redis:latest itself.
- 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.
We can also create the Redis container directly from the command line.
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.
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
If you are having debian/Ubuntu server use below command. Normally it will install the Redis server.
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.
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
sh: phpize: command not found
ERROR: `phpize’ failed
In my case, I got above error, So I have installed devel package using below command.
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.
If its still not enabled try to issue below command
Now if you still not succeeded with the yum install try the pecl install of Redis.
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
- Install plugin named Redis Object Cache plugin
- Go the Wp-Admin area of wordpress and click the “Object Cache” button.
- 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.
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.
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.