Content

DirectAdmin plugin for managing Redis instances

With this plugin end-users on an DirectAdmin server can easliy add and remove their redis instances.

It was developed by Kevin Bentlage and released to the public More information about this plugin can be found on Gifthub.

Installing plugin & Redis

Plugin installation

cd /usr/local/directadmin/plugins
git clone https://github.com/kbentlage/da-redis-management.git redis_management
sh redis_management/scripts/install.sh

Redis installation

cd /usr/local/directadmin/plugins/redis_management/setup
sh install.sh

Update

cd /usr/local/directadmin/plugins/redis_management
git pull

Configuration

By default, the plugin is working out-of-the box. But it can be needed to change serveral configuration settings.

The default settings are stored in /usr/local/directadmin/plugins/redis_management/php/Config/main.php.

If you need to change for example the location where the redis data is stored (default in /var/lib/redis), you can do this in “local.php”. Please do not change this in the “main.php” config file, because this file can be overwritten when a new version of this plugin is installed.

As from now you can find the Redis plugin in your Admin/User main menu, under “Extra Features”.

 

 

Selecting the “Extra Features” link will give you the opportunity to create or delete a Redis Instance with just one click.
The User can view here all existing Redis Instances. The Admin can also view all created Redis Instances.

Redis and WordPress, how to use?

Redis is a very smart cache mechanism, which works on the basis of a key -> value. This allows you to put a lot of data into a Redis cache object, which we can retrieve on the website with every visitor on the website in no time. Because of this, the entire often large and slow MySQL database does not have to be searched by every visitor, but the right data can be retrieved very efficiently using the key.

Since WordPress is completely based on the MySQL database and stores all data in it, we will make the WordPress website much faster with this way of storing and reading data. After all, all the requested data are immediately stored in the Redis cache with the first visitors, as a result of which this cache is getting bigger and MySQL needs to search less and less data.

That sounds nice, how do I install Redis in WordPress?

We have to adapt WordPress for a small part after which WordPress will save the data in MySQL and in the Redis cache database. A handy plugin has been written for this by Till Krüss, which is in the WordPress plugin store. We are going to install it.

To do this, we need to login into the WordPress backend. Once logged in, we click on Plugins -> and again on New plugins. Here we enter at the top right of the search form: Redis object cache. If you click on search, you will then see a similar result.

Install and activate the plugin.

You can now create a Redis database in Directadmin. Click on create Redis Instance and write down the data, which you need in the next step.

Then we have to enter this data into our wp-config.php file. You can find these at any time in the public_html folder of your WordPress installation. This includes your MySQL database login details. In this manual, I will adjust this via DirectAdmin. To do this, click on File Manager in the top DirectAdmin.

Next, go to domains -> mydomain.com -> public_html. Here you´ll see the wp-config.php, which we open through the Edit button to adjust.

Then, in the file below, look for the following line:

/** Sets up WordPress vars and included files. */

require_once(ABSPATH . 'wp-settings.php');

Above this line add the following code:

define('WP_REDIS_HOST', '127.0.0.1');

define('WP_REDIS_PASSWORD', 'your_password');

define('WP_REDIS_PORT', 'your_port');

Enable Redis in WordPress

Click on the blue button: Enable object cache to activate Redis on your own WordPress installation.

Once you have clicked on this button, Redis Cache for WordPress is activated and you will see the following screen. Here you can check the Redis cache status and you can possibly flush the cache if necessary. Your installation of Redis is now complete and your WordPress website will now have to be a lot faster.


In case you want to uninstall:

Cleanup redis

yum remove redis
rm -rf /var/lib/redis
rm -f /etc/redis.conf
rm -rf /etc/redis/

Remove plugin

rm -rf /usr/local/directadmin/plugins/redis_management/
rm -f /etc/sudoers.d/redis

Source

This article was written by: Alentejo Hosting.

Was this article helpful to you?

Leave a Reply