This article was contributed by the folks at RackNerd – a provider of shared hosting, reseller hosting, VPS hosting, dedicated servers, DRaaS, colocation, and more. If you are looking for a VPS with full root access to set up Redis on, be sure to review their latest LowEndBox special offers here.
Redis, or Remote Dictionary Server, was created by Salvatore Sanfilippo in 2009. It is an open-source project and provides an in-memory data structure platform. It implements a key-value distributed database supporting various types of data, such as sets, bitmaps, streams, and spatial indexes. The Redis is popularly used as a cache, message broker, and database.
Today, we will see how you can install and use the Redis software on your Ubuntu 20.04 system.
- Requirements
This tutorial is for Ubuntu 20.04, so make sure your operating system is running Ubuntu 20.04. Also, root access to the system is required before we proceed.
- Install Redis
It is an easy job to get Redis installed on your system because it is included in the repositories of Ubuntu 20.04.
Run the following commands to get Redis installed:
sudo apt update
sudo apt install redis-server
After the installation is done, Redis will automatically start running in the background. To make sure that the installation was successful, run the next command:
sudo systemctl status redis-server
If the installation were completed successfully, you would see the Redis server’s status as the output.
In case Redis is installed properly, but it fails to start, make sure that IPv6 is disabled on the server.
- Configuring remote access
By default, you can only connect to Redis through the local host at 127.0.0.1. However, you can also enable remote access for Redis.
To enable remote access, you need to open the config file for Redis. You can do this by the following command:
sudo nano /etc/redis/redis.conf
Now, find the line that says, “bind 127.0.0.1 ::1” and put a “#” before it to comment that line. You can now save the file and restart the Redis service by running this command.
sudo systemctl restart redis-server
To confirm that remote access has been configured, run the following command.
ss -an | grep 6379
If the output displays 0.0.0.0, it means that it is listening to all IP addresses on port 6379.
- Configure firewall
Now that we have configured the remote access for Redis. We need to configure the firewall for port 6379 so that incoming connections are allowed. Run the following command to enable traffic for Redis.
sudo ufw allow proto tcp from 192.168.111.0/24 to any port 6379
Make sure that you replace “192.1.168.111.0/24” with the IP address of your remote server. The firewall only allows traffic from this IP address.
To verify the remote access, you can run the following command on your remote machine:
redis-cli -h <Your_Redis_IP_Address> ping
If everything is working properly, you will see the output that says “PONG”.
Thanks for reading! Please leave any questions or feedback below.
Related Posts:
- Have you ever visited the web’s busiest hosting forum? LowEndTalk awaits. - September 27, 2022
- Grab the deals first by subscribing to our new deal alerts - September 16, 2022
- LowEndBox is on Instagram and TikTok! - August 5, 2022
Leave a Reply