Install & Configure Redis on RHEL / CentOS 8

Last modified on October 27, 2020 1 min read

HIRE US 🖐
We're available to do freelance project. Take a look at our services!

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

  1. Install Redis Server
  2. Test Redis
  3. Open Firewalld Port
  4. More Info
  5. Allow Redis in PHP

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. 🙂

Author

Hey, I'm Md Obydullah. I build open-source projects and write on Laravel, Linux server, modern JavaScript and more on web development.

Follow

Leave a Reply

Your email address will not be published. Required fields are marked *