How to Install Redis 6 on CentOS 7?

Installing Redis 6 on CentOS 7 improves the performance of Cache objects, the content generated by PHP, and the Database.

This version of Redis 6 can be divided into several different categories such as Security, performance, ease of use, and even some completely new functions such as:

  • SSL
  • ACL
  • RESP3
  • Client side caching: Caching at the client
  • Threaded I/O
  • Cluster support in Redis-benchmark and improved redis-cli cluster
  • Supports multiple Redis modules
  • Redis Cluster Proxy
  • RDB deletes itself when no longer in use
  • Psync2 optimized replication protocol
  • Support timeout setting
  • RDB loading is 20-30% faster

Install Redis 6 on CentOS 7

Step 1: SSH into the Linux server

To install Redis 6.2 on a CentOS 7 server you need to SSH into the server. If you do not know how to SSH, please refer to the following article:

Because the installation steps will take a long time, so to be safe, you should create a screen and run it on a backup screen when suddenly shutting down or losing an internet connection.

Step 2: Update the system

The first thing you should do is update the system with the following command.

yum update -y
yum install gcc make wget tcl

Step 3: Install Redis 6 on CentOS 7

To install you need to download source Redis from the homepage and unzip the installation.

cd /usr/local/src
tar xf 6.2-rc2.tar.gz
cd redis-6.2-rc2

Download redis

After you have extracted and moved into the directory, start compiling with the make command as follows.

And the build may take some time depending on your server resources, once completed you will get a message like the following.

Install Redis on CentOS 7 step 2

Now run the make test command to make sure the build is correct.

make test

The next step is to install Redis binaries with the make install command

make install

Step 4: Create Redis User

groupadd redis
adduser --system -g redis --no-create-home redis

Create a directory to store the database for Redis.

mkdir -p /var/lib/redis
chown redis: /var/lib/redis
chmod 770 /var/lib/redis

Step 5: Create Redis . configuration file

Now that Redis is installed, the next step is to configure Redis as follows.

mkdir /etc/redis
cp /usr/local/src/redis-6.2-rc2/redis.conf /etc/redis/

Then you find the supervised line and change it to supervised systemd as shown in the picture.

vi /etc/redis/redis.conf

supervised systemd

Step 6: Create the Redis system file

Now that Redis is installed and configured, the final step is to create a systemd unit file so that you can manage Redis services like a regular systemd service.

vi /etc/systemd/system/redis.service

Description=Redis Data Store
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown

Enable Redis

#Activate the same system
systemctl enable redis
#Start Redis
systemctl start redis
#Check status
systemctl status redis

Step 7: Check Redis Version

To check the Redis version, use the command below in the terminal.

redis-server --version

Install Redis PHP Extension

Step 1: Install Redis PHP Extension

To connect the communication between the Redis server and the website, you need to install the Redis PHP Extension. If you do not install the Extension, you can still connect through Predis. To install you do it quickly with the following command.

yum install php-pear php-devel
yum install php-redis -y

Step 2: Configure Redis as Cache Server

vi /etc/redis/redis.conf

Find and correct the following.

maxmemory 256mb
maxmemory-policy allkeys-lru

Step 3: Install Redis cache on WordPress

After installing Redis, you can configure Redis on your website to work. Each source code will have a different configuration. In this article, I only guide the configuration on WordPress using the Redis developer’s dedicated Plugin.

We will use the Redis Object Cache Plugin for configuration.

Before installing, open the wp-config.php file and add the following code to authenticate the key.

define('WP_CACHE_KEY_SALT', 'string');
define('WP_CACHE', true);

Next, install the Redis Object Cache Plugin. It installs a PHP script that helps WordPress communicate with Redis.

After installing the plugin you need to activate it. Navigate to Settings => Redis and click on “Enable Object Cache” and make sure Status shows “Connected”. If not, make sure you have added the configuration to the wp-config.php file as above.

So we have just finished the tutorial on Installing Redis 6 on CentOS 7. Hope the above article brings many new things to you. From there, it can help you set up performance improvement settings for your server and website.

About the Author: admin
The best hosting, domain and VPS servers coupon codes at help you save money when buying hosting, domain names, and servers.
You might like

Leave a Reply

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