If you’re building a web app that needs speed and real-time performance, Redis is your friend. It’s an open-source, in-memory data store that’s fast, lightweight, and great for caching and pub/sub messaging.
Before we dive in—if you’re looking for affordable and reliable VPS hosting, I highly recommend checking out RackNerd.
🔗 Get started with RackNerd
Now, let’s get Redis up and running on Ubuntu.
Step 1: Update Your System
Start by updating your package lists to make sure everything’s current:
sudo apt update
sudo apt upgrade -y
Step 2: Install Redis
Redis is available in Ubuntu’s default repositories, so installation is simple:
sudo apt install redis-server -y
This installs Redis and sets it up as a background service.
Step 3: Configure Redis
By default, Redis is set up for local development. If you’re deploying this in production, tweak the configuration.
Open the config file:
sudo nano /etc/redis/redis.conf
Key settings to check:
- Supervised mode: Make sure it’s set to
systemd
so Redis can be managed correctly by the system.
supervised systemd
- Bind address: Redis binds to
127.0.0.1
(localhost) by default. If you want remote access (not recommended without firewall/VPN), update this carefully:
bind 127.0.0.1
# bind 0.0.0.0 (uncomment with caution)
- Password protection (highly recommended):
requirepass your-strong-password
Save and close the file.
Step 4: Restart Redis to Apply Changes
sudo systemctl restart redis.service
Then enable Redis to start on boot:
sudo systemctl enable redis
Step 5: Test the Redis Installation
Use the Redis CLI:
redis-cli
If you set a password, authenticate first:
auth your-strong-password
Run a simple ping test:
ping
You should get:
PONG
Step 6: Secure Your Redis (Optional but Important)
If you’re using Redis on a server accessible to the public internet, do not leave it open. Here’s how to lock it down:
- Use a firewall (UFW example):
sudo ufw allow from your.ip.address to any port 6379
sudo ufw enable
- Or, tunnel Redis traffic through an SSH tunnel or VPN.
Step 7: Monitor and Manage
To check Redis status:
sudo systemctl status redis
To monitor Redis activity:
redis-cli monitor
Final Thoughts
Redis is powerful, but don’t just install and forget it. Secure it, monitor it, and make sure it’s tuned for your workload. Now you’ve got a solid setup on Ubuntu.
Want to boost your site with Redis-powered caching? Stay tuned for our next guide on integrating Redis with WordPress or Laravel.
Leave a Reply