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 it manually. So in this blog post we implement the Redis server using different methods. We only have to follow any of them.
Method 1. Install Redis Server as a docker container
In this method we are trying to install and run Redis server package as docker container. For that follow below steps.
- First Login into Plesk Panel
- Click extensions from the left side panel
- Type docker in the search box and choose docker extension
- Install Docker extension by clicking get it free button
- We will see the docker extension is installing in the popup window.
- Once the install got completed, the docker icon will be available in the plesk left side panel itself.
- After that go the Docker extension tab and search “redis” in the docker extension catalog search box.
- Click the run button next to the first redis docker image available from the official repository.
- First the redis image will be downloaded locally on your server and it will be visible in the popup window
- Once the download completed the redis docker image config option will show up automatically.
- From that Uncheck “Automatic port mapping ” option and give the port as 6379 as external too.
- After that click OK.
- The redis container will start automatically and we will see the start log.
- After that if we click the docker option from the Plesk left panel we will see the running status for the redis docker image.
This completes the installation of redis server through Plesk docker section. Now We can also confirm if the redis docker image is running in the server using netstat command. For that first log in to the Plesk server through SSH terminal as root user and issue below netstat command and look for port 6379 is listening in the server.
Now we also have the option to create the Redis container directly from the command line. For that first uninstall the docker image from Plesk terminal by using remove button available in the docker redis image.
Confirm the removal by clicking on Yes button. This action will uninstall the redis docker image.
Once the uninstall got completed, we will see below message.
After that go back to the SSH terminal and from the ssh terminal run below docker command.
From the command itself we can see, we are installing the latest redis docker image and binding the redis port to 6379 and giving the name as redis.
After running the docker run command if we go back to the Plesk docker section, we can see the redis image is running again.
Now we can verify the installed docker image using below command. So issue this command in the ssh terminal and we can see the redis docker image is running.
Also we can see the listening port for redis server is 6379 by running below netstat command in the ssh terminal.
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 docker image. For that first issue below command in the ssh terminal.
Now we’re attached to our redis docker container terminal and from there Let’s run below command.
Now we are in the redis terminal. From there run redis command “ping” and we will see the output as “pong”
Which confirms that the redis server installed in the server is working fine.
Below is the screenshot of SSH terminal after we issued few above discussed commands.
Okay, now if we don’t want to install the redis server as docker image, we have another option to install redis server as rpm package. So lets also see how this can be accomplished.
Method 2. Install Redis server using yum.
We only have to follow this method if we are not installing the Redis server using docker image as we mentioned in the first method.
So first thing is uninstall the redis docker container by clicking the “remove” button available in the Plesk docker terminal section.
Confirm the removal by clicking Yes button.
Wait some time and we will see the message as redis container removed.
Now go back our ssh terminal and first issue below command. Here we are trying to install Redis server using yum command if you have Centos Servers. For that run below commands.
Now If you are having debian/Ubuntu server use below command. Normally it will install the Redis server.
Now open file /etc/redis/redis.conf and make sure “supervised” value is set to “systemd” not “no”. After that restart the redis service again by issuing below command.
After that we can confirm the redis is running the server by issuing below netstat command again in the ssh terminal.
Okay, this completes the install of redis server on a plesk server and now we are proceeding with the installation of Redis php extension.
Install Redis PHP extension
Without redis php extensions our websites won’t be able to communicate with out redis server installed in the server. So lets see how redis php extension can be installed in our server. For that first issue below command. Here we assume that your website is using PHP version as 7.4. If your website PHP version is different, change the binary path location of below command accordingly.
|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 above. Open file /etc/yum.conf and set “gpgcheck” value to “0” and run “yum update” command.
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.
After the successful install of redis php extension. If we go to plesk panel and click tools and settings >> then under General Settings click php settings >> click 7.4.26 FPM application handler , from there we can see the “redis” php extension is enabled in the server.
Okay, this concludes the php-redis extension install in the server. Now lets proceed with the next section.
Install Redis-object-cache in WordPress
Lets see how can integrate the installed Redis cache server using WordPress plugin named ” Redis-object-cache”. Then only the caching will work for our WordPress websites. If your website is not WordPress use corresponding code or plugins available for integration. So follow below method if you have WordPress Website.
Here I already have a website name training.supporthost.in. I have also installed the wordpress application in it using Plesk Panel.
So first log in to the wp-admin area of our website. for that click on “login button” available under plesk wordpress toolkit section.
- A new browser window will open and wp-admin area will be available.
- From wp-admin area left panel, under plugins section click add new option
- Now search a plugin named “Redis Object Cache”
- The “Redis Object Cache” plugin will show up and click install now button.
- Wait untin the plugin got successfully installed
- After that, click activate button
- Now we will automatically redirected to settings >> redis section.
- From there use enable “redis object cache option
Now we will see the status message as Connected
Which means that, our word-press website is successfully connected to our redis server. This completes the install of redis cache plugin through wp-admin area.
Now 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.