// blog

How to Install and Configure Redis on a Linux VPS: Complete Caching Guide

August 19, 2026 · by CLIQHOST

How to Install and Configure Redis on a Linux VPS: Complete Caching Guide

If your web application is hammering the database with repeated queries, Redis can be the single change that dramatically cuts response times. Redis (Remote Dictionary Server) is an open-source, in-memory key-value store widely used for caching, session management, and message queuing.

In this guide, you will learn how to install, configure, and secure Redis on a NVMe VPS or SSD VPS running Ubuntu 22.04 or Debian 12 — from scratch to a production-ready setup.


What Is Redis and Why Does It Matter?

Redis operates entirely in RAM, delivering sub-millisecond latency for most operations. Common use cases include:

  • Caching — store results of expensive SQL queries or API calls so they are served instantly on subsequent requests
  • Session storage — replace slow file-based PHP sessions with fast Redis sessions
  • Message queues — pass tasks asynchronously between application components
  • Rate limiting — track and throttle requests per user or IP

Platforms such as WordPress, Laravel, Magento, and Django all have native or plugin-based Redis support.


Prerequisites

  • A Linux VPS running Ubuntu 22.04 or Debian 12
  • Root access or a user with sudo privileges
  • An active SSH connection to the server
  • Basic familiarity with the Linux command line

Step 1: Update the System

Always start with a system update to avoid dependency conflicts:

sudo apt update && sudo apt upgrade -y

This ensures you receive the latest stable Redis version from the official repositories.


Step 2: Install Redis

Redis is available in the default Ubuntu 22.04 and Debian 12 repositories:

sudo apt install redis-server -y

Confirm the installed version:

redis-server --version
# Redis server v=7.x.x ...

Enable and start the service:

sudo systemctl enable redis-server
sudo systemctl start redis-server

Check the status:

sudo systemctl status redis-server

You should see active (running) highlighted in green.


Step 3: Verify Redis Is Working

Use the built-in CLI client:

redis-cli ping
# PONG

Set and retrieve a test value:

redis-cli SET test_key "CliqHost Redis"
redis-cli GET test_key
# "CliqHost Redis"

If you see the expected responses, Redis is running correctly.


Step 4: Configure Redis — redis.conf

The main configuration file lives at /etc/redis/redis.conf. Open it with your editor:

sudo nano /etc/redis/redis.conf

4.1 Set supervised Mode

Because we are using systemd, change:

supervised no

to:

supervised systemd

4.2 Limit Memory (maxmemory)

For a server with 2 GB RAM shared between the application and Redis, allocate 512 MB:

maxmemory 512mb
maxmemory-policy allkeys-lru

The allkeys-lru eviction policy removes the least-recently-used keys when memory is full — perfect for a cache layer.

4.3 Persistence Settings

If Redis is used only for caching, disable persistence for maximum throughput:

save ""
appendonly no

If you need data to survive restarts (sessions, queues), enable AOF persistence:

appendonly yes
appendfsync everysec

Save the file and restart Redis:

sudo systemctl restart redis-server

Step 5: Secure Redis

By default, Redis listens only on 127.0.0.1, which is the correct setting for single-server deployments. Verify this in redis.conf:

bind 127.0.0.1 ::1

5.1 Set a Strong Password

Locate the commented # requirepass line and add:

requirepass YourLongAndComplexPasswordHere

Generate a strong password with:

openssl rand -base64 32

5.2 Disable Dangerous Commands

Rename or disable commands that could wipe your data:

rename-command FLUSHALL ""
rename-command FLUSHDB ""
rename-command CONFIG "CONFIG_SECRET_STRING"

5.3 Firewall Rules

Ensure port 6379 is not exposed to the internet. On a server protected by UFW firewall:

sudo ufw deny 6379

To allow a specific trusted IP only:

sudo ufw allow from 203.0.113.10 to any port 6379

Restart Redis to apply all configuration changes:

sudo systemctl restart redis-server

Step 6: Test Authentication

After setting a password, connect using:

redis-cli -a 'YourLongAndComplexPasswordHere' ping
# PONG

Or authenticate interactively:

redis-cli
127.0.0.1:6379> AUTH YourLongAndComplexPasswordHere
OK
127.0.0.1:6379> ping
PONG

Step 7: Integrate Redis with WordPress

If you run WordPress on a managed WordPress hosting plan or a VPS, you can enable Redis object caching to drastically reduce database load.

Install the Redis Object Cache Plugin

WordPress Admin → Plugins → Add New → search for Redis Object Cache → Install → Activate.

Then add the following constants to wp-config.php:

define('WP_REDIS_HOST', '127.0.0.1');
define('WP_REDIS_PORT', 6379);
define('WP_REDIS_PASSWORD', 'YourLongAndComplexPasswordHere');
define('WP_REDIS_TIMEOUT', 1);
define('WP_REDIS_READ_TIMEOUT', 1);
define('WP_REDIS_DATABASE', 0);

From the plugin dashboard, click Enable Object Cache. You will immediately notice a significant drop in SQL queries per page load.


Step 8: Monitor Redis

Watch live commands in real time:

redis-cli monitor

Check server statistics:

redis-cli info stats
redis-cli info memory

Key metrics to watch:

Metric What It Means
used_memory_human RAM currently used by Redis
keyspace_hits Requests served from cache
keyspace_misses Cache misses (data not found)
connected_clients Active client connections

A hits/misses ratio above 90% indicates an efficient cache configuration.


Step 9: Advanced Optimisations

Use Separate Redis Databases

Redis ships with 16 logical databases (0–15). Keep different data types isolated:

SELECT 0  # application cache
SELECT 1  # user sessions
SELECT 2  # rate limiting counters

Disable Transparent Huge Pages (THP)

Redis recommends disabling THP to avoid latency spikes:

echo never | sudo tee /sys/kernel/mm/transparent_hugepage/enabled

Add the same line to /etc/rc.local so the setting persists across reboots.

Set vm.overcommit_memory

echo 'vm.overcommit_memory = 1' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

This prevents the warning MISCONF Redis is configured to save RDB snapshots during fork operations.

For professional, hands-off server management, check out the server management services offered by CLIQHOST.


Conclusion

Redis is one of the most impactful additions you can make to a Linux server stack. With proper memory limits, an LRU eviction policy, a strong password, and a locked-down firewall, you have a fast and secure caching layer ready for production.

Looking for a high-performance environment to run Redis on? Explore the NVMe VPS plans at CLIQHOST for low-latency storage, or go with a managed dedicated server for large-scale deployments. Questions? Get in touch with our team — we are happy to help you get set up.

SHARE
// what clients say

What Our Clients Say

Real reviews from customers who trust CLIQHOST for performance, reliability and expert technical support.

★★★★★

"We moved our online shop from a foreign host and the difference is night and day — pages load instantly and support replies in minutes, in Romanian."

AM
Andrei M.
eCommerce owner · Chișinău
★★★★★

"Migrated 12 client sites to CLIQHOST. Free migration, zero downtime, and the cPanel setup is exactly what my team needed. Highly recommend."

EV
Elena V.
Web agency · Bălți
★★★★★

"Our NVMe VPS handles traffic spikes without a sweat. Full root, local datacenter, and billing in MDL — everything we wanted from a provider."

DC
Dmitri C.
SaaS founder · Chișinău