October 30, 2026 · by Alex M.
The performance of a modern web application largely depends on how fast the server responds to repeated requests. Relational databases are excellent for storing data, but querying them on every HTTP request costs time and resources. Redis solves exactly this problem: an in-memory data store, blazing fast, widely used for caching, session management, and message queues.
In this complete guide, you'll learn how to install, configure, and secure Redis on a Linux VPS from CLIQHOST step by step, with concrete command examples and configuration settings.
Redis (Remote Dictionary Server) is an open-source key-value data store that runs entirely in RAM. This makes it hundreds of times faster than a traditional database for read/write operations.
If you run a medium-to-high-traffic site on a CLIQHOST NVMe VPS, adding Redis can dramatically reduce your application's response time.
Before you begin, make sure you have:
sudo privilegesIf you don't have a server yet, you can quickly order a VPS SSD or VPS NVMe from cliqhost.com.
Always start by updating the package list:
sudo apt update && sudo apt upgrade -y
Redis is available in the official Ubuntu/Debian repositories:
sudo apt install redis-server -y
Check the installed version:
redis-server --version
Expected output:
Redis server v=7.0.15 sha=00000000:0 malloc=jemalloc-5.3.0 bits=64
Check the service status:
sudo systemctl status redis-server
If the service isn't running:
sudo systemctl start redis-server
sudo systemctl enable redis-server
redis.conf)The main configuration file is located at /etc/redis/redis.conf:
sudo nano /etc/redis/redis.conf
Since Ubuntu/Debian use systemd, find the line:
supervised no
And change it to:
supervised systemd
Without a limit, Redis can consume all available RAM. Add or modify:
maxmemory 256mb
maxmemory-policy allkeys-lru
Eviction policies explained (maxmemory-policy):
| Policy | Behavior |
|---|---|
allkeys-lru |
Evicts least recently used keys (recommended for cache) |
volatile-lru |
Evicts only keys with a TTL set |
noeviction |
Returns an error when memory is full (for critical data) |
allkeys-random |
Evicts random keys |
By default, Redis saves data to disk periodically (RDB snapshots). If you use Redis exclusively for caching, disable persistence for maximum performance:
save ""
For session storage, keep the defaults or enable AOF:
appendonly yes
appendfilename "appendonly.aof"
By default, Redis listens only on localhost (127.0.0.1) — this is the correct, secure behavior:
bind 127.0.0.1 -::1
Never expose Redis on a public IP without authentication and a firewall!
After making changes, restart Redis:
sudo systemctl restart redis-server
Even though Redis only listens on localhost by default, setting a password adds an extra security layer:
sudo nano /etc/redis/redis.conf
Find the line:
# requirepass foobared
Uncomment it and set a strong password:
requirepass Str0ng#Password2025!
Restart the service:
sudo systemctl restart redis-server
Test authentication:
redis-cli
127.0.0.1:6379> AUTH Str0ng#Password2025!
OK
127.0.0.1:6379> PING
PONG
If you need comprehensive server hardening, the CLIQHOST server management team can handle the full security setup for you.
redis-cli is the built-in command-line client. Common operations:
redis-cli -a Str0ng#Password2025!
Set and retrieve values:
SET website "cliqhost.com"
GET website
# Output: "cliqhost.com"
Set a value with expiration (TTL in seconds):
SETEX cache_homepage 3600 "<html>...</html>"
TTL cache_homepage
# Output: 3599
Server statistics:
INFO server
INFO memory
INFO stats
Total number of keys:
DBSIZE
sudo apt install php-redis -y
Verify the installation:
php -m | grep redis
# Output: redis
Open the PHP configuration file (adjust the version number):
sudo nano /etc/php/8.2/fpm/php.ini
Modify or add:
session.save_handler = redis
session.save_path = "tcp://127.0.0.1:6379?auth=Str0ng#Password2025!"
Restart PHP-FPM:
sudo systemctl restart php8.2-fpm
User sessions are now stored in Redis instead of disk — faster and easier to scale.
For WordPress hosted on a CLIQHOST VPS or WordPress hosting plan, install the Redis Object Cache plugin:
wp-config.php:define('WP_REDIS_HOST', '127.0.0.1');
define('WP_REDIS_PORT', 6379);
define('WP_REDIS_PASSWORD', 'Str0ng#Password2025!');
define('WP_REDIS_DATABASE', 0);
You'll immediately see reduced response times for dynamic pages.
redis-cli -a Str0ng#Password2025! monitor
This displays all commands processed in real time — useful for debugging, but resource-intensive in production.
redis-cli -a Str0ng#Password2025! INFO memory | grep -E 'used_memory_human|maxmemory_human|mem_fragmentation_ratio'
Sample output:
used_memory_human:12.50M
maxmemory_human:256.00M
mem_fragmentation_ratio:1.15
redis-cli -a Str0ng#Password2025! --latency
Enable slow command logging in redis.conf:
slowlog-log-slower-than 10000
slowlog-max-len 128
View slow commands:
redis-cli SLOWLOG GET 10
If UFW is active on your server, make sure port 6379 is not open to the public:
sudo ufw status
Port 6379 should not appear in the list of allowed rules for external sources. If Redis needs to be reached from a separate server (e.g., in a cluster), allow access only from a specific IP:
sudo ufw allow from 10.0.0.5 to any port 6379
Replace 10.0.0.5 with the private IP of your application server.
For high-traffic projects, a CLIQHOST dedicated server provides the RAM and throughput Redis needs to operate at full capacity.
Redis recommends disabling THP to reduce latency:
echo never | sudo tee /sys/kernel/mm/transparent_hugepage/enabled
To persist across reboots, add to /etc/rc.local:
echo never > /sys/kernel/mm/transparent_hugepage/enabled
sudo sysctl vm.overcommit_memory=1
echo 'vm.overcommit_memory = 1' | sudo tee -a /etc/sysctl.conf
This prevents "fork failed" errors when creating RDB snapshots.
sudo sysctl -w net.core.somaxconn=65535
echo 'net.core.somaxconn = 65535' | sudo tee -a /etc/sysctl.conf
| Hosting Type | Redis Recommended? | Notes |
|---|---|---|
| Shared Hosting cPanel | ❌ / Limited | Depends on provider; check availability on CLIQHOST cPanel hosting |
| VPS SSD / NVMe | ✅ Absolutely | Full control, dedicated resources |
| Dedicated Server | ✅ Ideal | Abundant RAM, minimal latency |
| Application Cluster | ✅ Redis Cluster | Multiple nodes, automatic replication |
For production apps with high traffic, a managed dedicated server from CLIQHOST provides all the resources Redis needs to shine.
# Install
sudo apt install redis-server -y
# Status
sudo systemctl status redis-server
# Restart
sudo systemctl restart redis-server
# Test connection
redis-cli -a PASSWORD ping
# Full info
redis-cli -a PASSWORD INFO
# Flush current database cache (careful in production!)
redis-cli -a PASSWORD FLUSHDB
# Flush all databases
redis-cli -a PASSWORD FLUSHALL
Redis is one of the most valuable tools you can add to a Linux server to boost web application performance. Through intelligent caching, PHP session management, and reduced database load, Redis dramatically transforms response times for dynamic sites.
If you need a server to deploy Redis without the hassle, choose a CLIQHOST NVMe VPS — dedicated resources, ultra-fast NVMe storage, and responsive technical support. Or contact us to get a personalized recommendation based on your project's needs.
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."
"Migrated 12 client sites to CLIQHOST. Free migration, zero downtime, and the cPanel setup is exactly what my team needed. Highly recommend."
"Our NVMe VPS handles traffic spikes without a sweat. Full root, local datacenter, and billing in MDL — everything we wanted from a provider."