Install Redis on Ubuntu 22.04

Install Redis pada Ubuntu 22.04

  • Update index repository
root@ubuntu-2204:~# apt update
  • Install Redis
root@ubuntu-2204:~# apt install redis-server
  • Enable redis service
root@ubuntu-2204:~# systemctl enable --now redis-server
root@ubuntu-2204:~# systemctl status redis-server
  • Cek status listen port dengan netstat, pastikan redis listen pada port 6379
root@ubuntu-2204:~# netstat -tulpn | grep redis
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      1862/redis-server 1
tcp6       0      0 ::1:6379                :::*                    LISTEN      1862/redis-server 1
  • Verifikasi redis
root@ubuntu-2204:~# redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set test "It works!"
OK
127.0.0.1:6379> get test
"It works!"
127.0.0.1:6379> exit

  • Setting redis password
  • uncomment baris requirepass masukan password
  • uncomment baris bind 127.0.0.1 ::1
  • restart service redis
root@ubuntu-2204:~# nano /etc/redis/redis.conf

requirepass sys-ops.id
bind 127.0.0.1 ::1

root@ubuntu-2204:~# systemctl restart redis-server
  • Verifikasi redis password
root@ubuntu-2204:~# redis-cli
127.0.0.1:6379> ping
(error) NOAUTH Authentication required.

127.0.0.1:6379> auth sys-ops.id
OK
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> exit

  • Install Plugin Redis Object Cache pada WordPress
  • Edit file wp-config.php lalu tambahkan baris berikut
root@ubuntu-2204:~# nano /var/www/jellyfish.rainui.cloud/wp-config.php

define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', '6379' );
define( 'WP_REDIS_DATABASE', 0 );
define( 'WP_REDIS_PASSWORD', 'sys-ops.id' );
  • Enable Object Cache pada Setting > Redis
  • Plugin Redis Object Cache pada WordPress berhasil terhubung ke redis server

herdiana3389

A system administrator with skills in system administration, virtualization, linux, windows, networking, cloud computing, container, etc.