Install & Configure Redis on RHEL / CentOS 8
Redis is an open-source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. Today we’ll install & configure Redis on RHEL / CentOS 8 server.
Table of Contents
Install Redis Server
Redis server is available in default CentOS 8 repositories. To install the Redis server package run this command:
sudo dnf install -y redis
Now enable & start Redis using:
# enable
sudo systemctl enable redis
# start
sudo systemctl start redis
Check Redis server version to confirm the installation:
redis-server -v
Let’s check redis-cli
:
# start cli
redis-cli
# type ping
127.0.0.1:6379> ping
# output
PONG
# type exit to exit cli
127.0.0.1:6379> exit
Test Redis
Start redis cli and try to set & get data:
# start cli
redis-cli
# set data
set myName "Obydul"
# get data
get myName
# output
"Obydul"
# type exit to exit cli
127.0.0.1:6379> exit
If you see the results like above then Redis is working on your server perfetly.
Open Firewalld Port
If you’re using Firewalld, then follow this step otherwise skip this step. Let’s open Redis port 6379 permanently:
sudo firewall-cmd --add-port=6379/tcp --permanent
We’ve opened the Redis port. We can also allow external server IP to access our Redis server. To do this, we need to provide access like this:
sudo firewall-cmd --zone=redis --add-source=CLIENT_IP_ADDRESS --permanent
Replace CLIENT_IP_ADDRESS
with your external server IP.
The reload the firewall:
sudo firewall-cmd --reload
More Info
To allow remote connection we’ve to bind remote IP. Add the external server IP after bind 127.0.0.1
:
# open config file
sudo nano /etc/redis.conf
# find 'bind' and add IP
bind 127.0.0.1 CLIENT_IP_ADDRESS
To know more about Redis, please read their documentation.
Allow Redis in PHP
To allow Redis in PHP, we need to install & configure phpredis. Please have a look at this article: Install phpredis on CentOS 8 / RHEL 8.
That’s it. Thanks for reading. ?Comment
Preview may take a few seconds to load.
Markdown Basics
Below you will find some common used markdown syntax. For a deeper dive in Markdown check out this Cheat Sheet
Bold & Italic
Italics *asterisks*
Bold **double asterisks**
Code
Inline Code
`backtick`Code Block```
Three back ticks and then enter your code blocks here.
```
Headers
# This is a Heading 1
## This is a Heading 2
### This is a Heading 3
Quotes
> type a greater than sign and start typing your quote.
Links
You can add links by adding text inside of [] and the link inside of (), like so:
Lists
To add a numbered list you can simply start with a number and a ., like so:
1. The first item in my list
For an unordered list, you can add a dash -, like so:
- The start of my list
Images
You can add images by selecting the image icon, which will upload and add an image to the editor, or you can manually add the image by adding an exclamation !, followed by the alt text inside of [], and the image URL inside of (), like so:
Dividers
To add a divider you can add three dashes or three asterisks:
--- or ***

Comments (0)