Jumat, 15/11/2024 - 11:01 WIB
IndonesianArabicEnglishRussianGermanFrenchChinese (Simplified)JapaneseMalayHindi

TERBARU

INTERNETTEKNOLOGI

Easy Way to Install and Secure Redis on Ubuntu 20.04

image_pdfimage_print

Redis is an open-source (BSD licensed), in-memory data structure store. You can use it as a Memcached alternative to store simple key-value pairs. Moreover, you can use it as a NoSQL database or even a message broker with the Pub-Sub pattern. Redis is written in C programming language. The Redis project is developed and maintained by a project core team and, as of 2015, is sponsored by Redis Labs .

ADVERTISEMENTS
Kartu ATM di Rumah, Action Mobile di Tangan

This tutorial will help you install the Redis server and PHP extensions on an Ubuntu 20.04 LTS system.

ADVERTISEMENTS
Bank Aceh Syariah Mengucapkan Selamat Hari Pahlawan 10 November 2024

Table of contents:

  1. Prerequisites
  2. Install Redis
  3. Configure Redis
  4. Install PHP Extension (Optional)
  5. Connect to Redis Server
  6. Managing the Redis Service

Step 1: Prerequisites

  • System running Ubuntu 20.04
  • Access Terminal Command line
  • Sudo or root privileges on local or remote machines

Step 2: Install Redis

Redis packages are available under the default apt repository for the installation of Redis on an Ubuntu VPS.

ADVERTISEMENTS
Memperingati 96 Tahun Sumpah Pemuda dari Bank Aceh Syariah

Start by updating the packages to the latest version. Run the following command:

ADVERTISEMENTS
Selamat & Sukses atas Pelantikan Ketua DPRA, Wakil Ketua I DPRA dan Wakil Ketua II DPRA
sudo apt update

Ⓒ Hak cipta foto di atas dikembalikan sesungguhnya kepada pemilik foto

ADVERTISEMENTS
Pertemuan Tahunan Perbankan Syariah 2024

Install Redis using the following command.

ADVERTISEMENTS
Selamat Memperingati Hari Santri Nasional
sudo apt install redis-server

Ⓒ Hak cipta foto di atas dikembalikan sesungguhnya kepada pemilik foto

Once the installation is completed, you can check the version of Redis using the following command.

redis-server -v

Ⓒ Hak cipta foto di atas dikembalikan sesungguhnya kepada pemilik foto

Step 3: Configure Redis

Redis can start without a configuration file using a built-in default configuration. Aim to make Any extra parameter exchange, you can use ict configuration file: /etc/redis/redis.conf. Edit the Redis configuration file in a text editor to make changes:

sudo nano /etc/redis/redis.conf
Configure Memory

Update the following values ​​in the Redis configuration file. You can use its configuration file /etc/redis/redis.conf::

maxmemory 256mb
maxmemory-policy allkeys-lru

Configure supervisord

For Ubuntu, we can safely select the systemd as the supervised so that Redis can interact with your supervision tree. You can use its configuration file /etc/redis/redis.conf:

Ⓒ Hak cipta foto di atas dikembalikan sesungguhnya kepada pemilik foto

Binding to localhost

By default, the Redis server doesn’t accept remote connections. You can connect to Redis only from 127.0.0.1 (localhost) – the machine where Redis is running.

Berita Lainnya:
BSSN Akui Sistem Elektronik Pemerintah Rentan Disusupi Judi Online

If you are using a single server setup where the client connecting to the database is also running on the same host, you should not enable remote access. You can use its configuration file /etc/redis/redis.conf::

bind 127.0.0.1 ::1

Ⓒ Hak cipta foto di atas dikembalikan sesungguhnya kepada pemilik foto

Verify redis is listening on all interfaces on port 6379. Run the following command:

ss -an | grep 6379

Ⓒ Hak cipta foto di atas dikembalikan sesungguhnya kepada pemilik foto

Configure Password

Configuring a Redis password enables one of its two built-in security features – the auth command, which requires clients to authenticate to access the database. You can use its configuration file /etc/redis/redis.conf::

Ⓒ Hak cipta foto di atas dikembalikan sesungguhnya kepada pemilik foto

Redis for the changes to take effect.

sudo systemctl restart redis-server

Step 4: Install PHP Extension (Optional)

Next, if you need to use Redis with a PHP application, you need to install Redis PHP extension on your Ubuntu system. To install the Redis PHP extension, type:

sudo apt install php-redis

Ⓒ Hak cipta foto di atas dikembalikan sesungguhnya kepada pemilik foto

The installer will automatically enable the redis extension for all the pre-installed PHP versions. If your installer new PHP version after this, you can use the below command to help the redis module. Run the following command:

sudo phpenmod -v <Any PHP Version> -s ALL redis

Step 5: Connect to Redis Server

Redis provides redis-cli utility to connect to the Redis server. Run the following command:

redis-cli

Ⓒ Hak cipta foto di atas dikembalikan sesungguhnya kepada pemilik foto

Few more examples of the redis-cli command-line tool.

redis-cli info
redis-cli info stats
redis-cli info server

You can find more details about redis-cli here .

Berita Lainnya:
10 Rekomendasi HP untuk Live TikTok Terbaik yang Anti Lemot

Step 6: Managing the Redis Service

Now that you have your service up and running, let’s go over basic management commands.

To stop your service, run this command:

sudo systemctl stop redis-server

To start your service, run this command:

sudo systemctl start redis-server

To disable your service, run this command:

sudo systemctl disable redis-server

To enable your service, run this command:

sudo systemctl enable redis-server

To status your service, run this command:

sudo systemctl status redis-server

Ⓒ Hak cipta foto di atas dikembalikan sesungguhnya kepada pemilik foto

1 2

Reaksi & Komentar

وَإِذْ فَرَقْنَا بِكُمُ الْبَحْرَ فَأَنجَيْنَاكُمْ وَأَغْرَقْنَا آلَ فِرْعَوْنَ وَأَنتُمْ تَنظُرُونَ البقرة [50] Listen
And [recall] when We parted the sea for you and saved you and drowned the people of Pharaoh while you were looking on. Al-Baqarah ( The Cow ) [50] Listen

Berita Lainnya

Tampilkan Lainnya Loading...Tidak ditemukan berita/artikel lainnya.
IndonesianArabicEnglishRussianGermanFrenchChinese (Simplified)JapaneseMalayHindi