Redis is an in-memory, encrypted data store that is frequently used for caching, message brokering, and enhancing application speed. Installing and turning on Redis on CentOS and Ubuntu systems is described in this guide.
Table of Contents
Why install Redis on CentOS and Ubuntu?
Installing Redis on CentOS or Ubuntu gives you a high-performance, in-memory database that accelerates web applications, supports caching, session management, and message queuing, while offering scalability and persistence for modern development needs.
Install Redis on CentOS
- Update System Packages
Before installing any new software, it’s important to update your system’s package index to guarantee you have the latest versions of dependencies and security patches.sudo yum update -y
- Install Redis
Install Redis from CentOS’s default repository. This will also install any required dependencies automatically.sudo yum install redis -y
- Enable and Start Redis Service
Enable Redis to start automatically at boot and start the service immediately:sudo systemctl enable redis sudo systemctl start redis
- Verify Redis Service Status
Check if Redis is running correctly with the following command:sudo systemctl status redis
You should see active (running) in the output, confirming that Redis is up and running.
- Test Redis CLI
Connect to Redis using the command-line interface and send a ping to verify connectivity:redis-cli ping
Expected output:
PONG
Install Redis on Ubuntu
- Update Package List
Update your package index to ensure you’re installing the latest available version of Redis:sudo apt update
- Install Redis
Install Redis server using Ubuntu’s package manager:sudo apt install redis-server -y
- Enable and Start Redis
Make Redis start automatically on boot and start the service immediately:sudo systemctl enable redis-server sudo systemctl start redis-server
- Check Redis Status
Verify that Redis is running properly:sudo systemctl status redis-server
Look for active (running) to confirm the service is operational.
- Test Redis Connectivity
Use Redis CLI to check if Redis is responding:redis-cli ping
Expected output:
PONG
A PONG response confirms Redis is working and ready for use.
Secure and Optimise Redis (Optional)
- Edit Redis configuration:
sudo nano /etc/redis/redis.conf
- Suggested configurations:
- Enable supervision for systemd
- Restrict access to localhost
- Configure password authentication with requirepass
- Restart Redis to apply changes:
sudo systemctl restart redis
Conclusion
You have successfully installed Redis on both CentOS and Ubuntu systems. With Redis up and running, you can now use its high-speed in-memory capabilities to enhance application performance, implement caching, manage sessions efficiently, and scale your applications seamlessly.
Need to update your system’s host configurations? Learn How to update hosts file entry on Windows, Ubuntu and Mac