How to install Redis server on OpenliteSpeed ​​web server

After installing Redis-server and Memcached object cache during OpenLiteSpeed ​​installation, I tried to activate it in LiteSpeed ​​Cache plugin , but the connection test to Redis server failed.

When I was configuring CyberPanel, I installed both object caches, but they didn’t actually work, so I looked up how to install them. Fortunately, there were a lot of resources, so I was able to install them without much difficulty.

One thing I had trouble with during the installation process was that the lsphp command did not work. This command is not required, but it was necessary to verify, so it took a lot of time to troubleshoot.

I won’t explain it because it’s not a big problem. I’ll just show you the process of installing Redis Sever.

Why Use Redis?

redis server

I was using Memcached before, but I saw an article saying that Redis is better. Here’s why I think Redis is better.

  • Versatile: Redis supports a variety of data structures and can be used for complex data processing.Memcached is limited to a simple key-value cache.
  • Persistence: Data can be persisted to disk, so it can persist even after a system restart. Memcached, on the other hand, is memory-based, so data can be lost.
  • Scalability: Redis supports clustering and provides high availability and replication capabilities.
  • Versatile Uses: Redis can be used for a variety of purposes, including caching, message brokering, and session storage.

Memcached provides simple and fast caching, but does not support advanced features such as data persistence or handling complex data structures, so WordPress users prefer Redis.

How to install redis server

Let’s learn how to install a Redis object cache on Ubuntu Server and Openlitespeed web server.

※ If there is no response during the command input process, you can switch to root authority by entering the sudo su – command.

Check if installed

redis-cli

Use the command above to check if Redis is installed. If a command no found error occurs, it is not installed.

Install

sudo apt update
sudo apt install redis server

If it is not installed, you can proceed with the installation by entering the command above.

Check if it works

redis server
sudo systemctl start redis server

Once the installation is complete, you can check if Redis is working by entering the command above. If it is working, you will see Active as shown above.

Autorun settings

sudo systemctl enable redis server

If it doesn’t work, enter the command above to set it to run automatically after reboot.

Setting up Redis

sudo nano /etc/redis/redis.conf

You can enter the settings by entering the command above.

maxmemory 256mb

maxmemory-policy allkeys-lru

Please find the two above, remove the #(comment) and modify them.

  • maxmemory: Specifies the maximum amount of memory that Redis can use.
  • maxmemory-policy allkeys-lru: Sets the policy to determine which data to delete when the memory limit is reached.

The reason for the above settings is to prevent excessive memory usage and increase cache efficiency.

Installing PHP Extension Modules

sudo apt install lsphp82-redis

You will need to install the PHP extension to connect to the Redis database. The important thing to note here is that you should replace ‘lsphp82’ with the version of PHP currently installed on your server.

To check your server PHP version, go to the ‘Tools’ menu in WordPress, select ‘Site Health’, then go to the ‘About’ tab and check your server information.

To check the PHP version on a server other than WordPress, type the command ‘php -v’.

Restart the web server

sudo systemctl restart lsws

If everything went well, you can restart the web server by entering the command above.

LiteSpeed ​​Cache plugin settings

redis server

Once you have completed installing the Redis server, now go to the LiteSpeed ​​Cache plugin and enable the object cache and set the method to Redis. After that, set the port to 6379 and save the changes.

Then you can check the status. If it is installed properly, it will show as ‘Activated’ and the connection test will show as ‘Passed’.

Since the Redis server is an object cache widely used by WordPress users, please refer to the explanation above to complete the installation and configuration, then activate it.

▶ How to fix HTTPS redirect not working in OpenLiteSpeed

▶ How to solve ‘efficient cache policy’ – Openlitespeed webserver

▶ How to install the OpenLiteSpeed ​​(OLS) web server on Lightsail

Leave a Comment

Your email address will not be published. Required fields are marked *