Home Our service Dashboard
1 week ago
ارما

how to install redis on ubuntu 2404

در این مقاله چه میخوانیم?

If you are looking to speed up your site or application or set up a good cache, Redis is one of the best choices. In this tutorial, we will install Redis on Ubuntu 24.04, get it up and running, and configure it to make it more secure.

Prerequisites for installing Redis?

  • A server or VPS with Ubuntu 24.04 installed.
  • SSH access to the server (meaning you can connect via terminal and run commands).

Step 1: Update the system

First of all, like any other installation, update the system so that everything is up to date. What's new:

sudo apt update
sudo apt upgrade -y

Step 2: Install Redis

Now you need to install Redis on your system with the following command and start configuring it.


sudo apt install redis-server -y
 

After installation, you can make sure it is installed and see what version it is:


redis-server --version

 

Step 3: The path Redis Setup

Redis is started by default, but check to make sure it is enabled:


sudo systemctl enable redis-server Enable Redis
sudo systemctl start redis-server Start 
sudo systemctl status redis-server Redis Status
 

If it says active (running), it is working properly.

Step 4: Redis Configuration

The address of the Redis configuration file usually goes here

sudo nano /etc/redis/redis.conf

There are a few important things here:

 To be accessible only from local, I mean local, the server of your site. Don't confuse local with your computer. Local means whatever computer you install it on.

  bind 127.0.0.1 ::1
 

 Check the Redis port, which is usually 6379, which may change from time to time


  port 6379
 

* If you want Redis to run in the background (usually like this):

  daemonize yes
 

After making changes, save and close the file.

Step 5: Set a password for Redis (very important)

If you don't want anyone to connect to Redis, set a password for it


sudo nano /etc/redis/redis.conf

requirepass YekRamzKhafan123
 

 

Replace `YekRamzKhafan123` with your desired password, but make it strong!

Then restart Redis Start:


sudo systemctl restart redis-server
 

Step 6: Test Redis

Now it's time to see if Redis is working properly:

redis-cli
 

Run the following command without the password:


ping
 

If it says `NOAUTH`, it means we need to enter a password.

Now enter your password:


auth YekRamzKhafan123
 

If it says `OK`, it means you entered correctly.

Now `ping` again:


ping
 

If it says `PONG` means Redis is responding.

You can save something as a test:

SET testkey "Hello Redis!"
GET testkey
 

If it returns `Hello Redis!`, then everything is OK.

To exit, type:


exit

So, so far we've installed Redis, run it, given it a password, and even run a test. Now you can use it in your projects, whether for caching data or as a lightweight and fast database.

قطعا تو ذهنت سوال داری

چرا زنگ نمیزنی که برات حلش کنیم؟

اینجا میتونه شروع راه تو باشه

تماس با پشتیبان

درباره باریز

At Bariz, we are more than just a web design and SEO team; we are a family of creatives and digital experts who combine art and technology to take businesses to the next level.

Our goal is to create unique digital experiences that are not only beautiful but impactful and result-driven.

Contact us

info@bariz.tech

© Copyright 2024 - bariz. All Right Reserved

پشتیبان شماره 2

آنلاین

پیامی برای نمایش وجود ندارد