How to Install Redis® on Ubuntu 24.04?
Introduction
If you want to skyrocket your app’s performance and speed, Redis® is one of the never-fail solutions. It is an in-memory key-value store that improves your database queries; thus, it enhances the performance of web applications. Redis finds applications in caching, real-time analytics, session management, etc. It is suitable for high-hit websites or fast back-ends to improve performance rapidly for other applications. It gives great enhancements to performance.
Cantech offers industrial-grade Linux VPS hosting, shared hosting, and reseller hosting solutions. For a Redis® database or cache, we assure you high availability, enhanced security, and smooth performance on our Linux VPS hosting. Our servers are optimally configured for Redis® to enable business or development to scale well.
Why Choose Redis®?
Redis is among the most considered in-memory data stores in the world. Here is why:
- Lightning-Fast Performance: Redis® keeps the data in RAM and offers much faster data retrieval than traditional databases.
- Data Persistence: Redis® uses two persistence methods: Append Only File (AOF) and Redis Database File (RDB).
- High scalability: Redis enables very high scalability with millions of requests processed per second; the most suitable solution for large applications.
- Rich data structures: It supports strings, lists, sets, sorted sets, hashes, bitmaps, geospatial indexes, and streams.
- Replication and high availability: Redis® has primary-replica with an option for automatic failover and high availability.
- Easy commands and configuration: The syntax is so simple that it is easy for a newbie to learn and for an expert to get started.
Cantech supercharges high-performance VPS hosting that you can dedicate totally to Redis® which will ensure you enjoy smooth operation whether you are running web applications, databases, or caching and you get superior SSD storage.
Prerequisites
Before installing Redis®, ensure you have:
- An Ubuntu 24.04 server
- A non-root user with sudo privileges
- A reliable internet connection
For a smooth experience hosting Redis, check out our Linux dedicated server hosting, equipped with SSD storage and full root access.
Steps to Install Redis on Ubuntu 24.04
Step 1: Update Your System
Make sure that you update your system packages before installing new software. Run the following command to update your system!
sudo apt update && sudo apt upgrade -y
This ensures your Ubuntu 24.04 system has the latest security updates and bug fixes.
Step 2: Install Redis on Ubuntu 24.04
Now, install Redis® using the package manager:
sudo apt install redis-server -y
Once installed, verify the installation by checking the Redis® version:
redis-server --version
You should see an output
similar to:
Redis server v=7.0.15
Step 3: Configure Redis® for Security and Performance
By default, Redis is set up to listen on 127.0.0.1
. To modify the configuration, you have to edit the Redis configuration file.
sudo nano /etc/redis/redis.conf
Look for the following directives and modify them if needed:
bind 127.0.0.1 ::1
Locate the port directive in the Redis® configuration file and check that it uses the default port, or change it to another available TCP port on your server.
port 6379
Check the daemonize directive in the configuration file and ensure it is set to ‘yes’ so that Redis® runs as a background service.
daemonize yes
Save and exit the file (Ctrl+X → Y → Enter).
Enable Redis® to start on boot:
sudo systemctl enable redis
Restart Redis® to apply the changes:
sudo systemctl restart redis
Check if Redis® is running:
sudo systemctl status redis
If Redis® is active, you should see the following message:
Active: active (running)
Step 4: Secure Redis® with a Password
Security is a crucial aspect of managing Redis®. To set a password, open the Redis® configuration file:
sudo nano /etc/redis/redis.conf
Find the line starting with # requirepass and change it to:
requirepass your-strong-password
Save and restart Redis®:
sudo systemctl restart redis
Use the redis-cli
tool or a compatible app module to connect to the Redis server. Then test the setup by writing sample data to the default database.
Establish a connection with the Redis server.
redis-cli
Now, authenticate with your password:
AUTH your-strong-password
A successful authentication returns ok.
Test the database server connection using the PING
command.
127.0.0.1:6379> ping
Output:
PONG
If the server responds, verify key setting by running
For secure Redis® hosting, consider Cantech’s dedicated servers with DDoS protection and firewall security.
Step 5: Test Redis®
To confirm that Redis® is functioning correctly, try setting and retrieving a key-value pair:
redis-cli SET testkey "Hello, Redis!" GET testkey
If everything is set up correctly, you will see:
"Hello, Redis!"
Step 6: Enable Persistence (Optional but Recommended)
To ensure data isn’t lost on server reboots, enable Redis® persistence. Edit the Redis® configuration file:
sudo nano /etc/redis/redis.conf
Uncomment and set:
save 900 1 save 300 10 save 60 10000
Restart Redis®:
sudo systemctl restart redis
Conclusion
You have successfully installed and configured Redis® on Ubuntu 24.04 using the steps mentioned above. Whether you use it for caching, message brokering, or real-time analytics, Redis can significantly improve your applications overall performance .
If you are looking for a fast, reliable, and highly scalable hosting solution for your Redis-based applications, choose Cantech. The Linux VPS is perfectly suited for running Redis workloads.
FAQs
Is Redis® free to use?
Yes! Redis has open-source code with a free license; the current license is the BSD license. Therefore, developing on Redis and using it commercially will be allowed.
Can Redis® be used as a primary database?
Although Redis is generally a caching layer, some applications configure it as the primary database while ensuring that persistence is enabled.
What is the default port for Redis®?
Redis runs primarily on port 6379.
How can I monitor Redis® performance?
You can use the command:
redis-cli info
This provides key metrics about Redis® performance, memory usage, and connected clients.
Can I host Redis® on shared hosting?
Redis® requires specific server configurations and is best suited for VPS hosting or dedicated servers.
How do I restart Redis® if I make changes?
Simply run:
sudo systemctl restart redis