Deploy redis-commander

  1. Buat file docker-compose.yml
version: '3'

services:
  redis-commander:
    container_name: redis-commander
    hostname: redis-commander
    image: ghcr.io/joeferner/redis-commander:latest
    restart: always
    ports:
      - "8081:8081"
    #make it persistent
    volumes:
      - redmon-data:/redis-commander/config
    networks:
      - redmon-net

networks:
  redmon-net:

volumes:
   redmon-data:
  1. Run dengan docker compose up -d
redis-commander

redis-commander


Deploy phpCacheAdmin

  1. Buat file docker-compose.yml
version: '3'

services:
  phpcacheadmin:
    image: robinn/phpcacheadmin
    ports:
      - "8081:80"
    volumes:
      - $PWD/config.php:/var/www/html/config.php
  1. Buat file config.php, disini kita tambahkan otentikasi redis server
<?php
/**
 * This file is part of phpCacheAdmin.
 *
 * Copyright (c) Róbert Kelčák (https://kelcak.com/)
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

return [
    // The order of the items also changes the position of the sidebar links.
    // You can comment out (delete) any dashboard except ServerDashboard because it's a default dashboard.
    'dashboards' => [
        // you cant disable server dashboard
        RobiNN\Pca\Dashboards\Server\ServerDashboard::class,
        RobiNN\Pca\Dashboards\Redis\RedisDashboard::class,
        // disable memcached, opcache and apcu dashboard
        //RobiNN\Pca\Dashboards\Memcached\MemcachedDashboard::class,
        //RobiNN\Pca\Dashboards\OPCache\OPCacheDashboard::class,
        //RobiNN\Pca\Dashboards\APCu\APCuDashboard::class,
    ],
    'redis'      => [
        [
            'name' => 'server-redis1', // Optional
            'host' => '192.168.1.69', // Optional, when a path is specified
            'port' => 6379, // Optional, when the default port is used
            //'database' => 0, // Optional
            //'username' => '', // Optional, requires Redis >= 6.0
            'password' => 'PasswordRedisKamu', // Optional
            //'path'     => '/var/run/redis/redis-server.sock', // Optional
        ],
        [
            'name' => 'server-redis2', // Optional
            'host' => '192.168.2.69', // Optional, when a path is specified
            'port' => 6379, // Optional, when the default port is used
            //'database' => 0, // Optional
            //'username' => '', // Optional, requires Redis >= 6.0
            'password' => 'PasswordRedisEnte', // Optional
            //'path'     => '/var/run/redis/redis-server.sock', // Optional
        ],

    ],
    'timeformat' => 'd. m. Y H:i:s',
    'twigdebug'  => false,
    /*'auth'       => static function (): void {
        // Example of authentication with http auth.

        $username = 'admin';
        $password = 'pass';

        if (
            !isset($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) ||
            $_SERVER['PHP_AUTH_USER'] !== $username || $_SERVER['PHP_AUTH_PW'] !== $password
        ) {
            header('WWW-Authenticate: Basic realm="phpCacheAdmin Login"');
            header('HTTP/1.0 401 Unauthorized');

            echo 'Incorrect username or password!';
            exit();
        }

        // Use this section for the logout.
        // It will display a link in the sidebar.
        if (isset($_GET['logout'])) {
            $is_https = (
                (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === 'on' || $_SERVER['HTTPS'] === 1)) ||
                (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')
            );

            header('Location: http'.($is_https ? 's' : '').'://reset:reset@'.($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']));
        }
    },*/
    // Decoding/Encoding functions
    'encoding'   => [
        'gzcompress' => [
            'view' => static fn (string $value): ?string => extension_loaded('zlib') && @gzuncompress($value) !== false ? gzuncompress($value) : null,
            'save' => static fn (string $value): string => extension_loaded('zlib') ? gzcompress($value) : $value,
        ],
        'gzencode'   => [
            'view' => static fn (string $value): ?string => extension_loaded('zlib') && @gzdecode($value) !== false ? gzdecode($value) : null,
            'save' => static fn (string $value): string => extension_loaded('zlib') ? gzencode($value) : $value,
        ],
        'gzdeflate'  => [
            'view' => static fn (string $value): ?string => extension_loaded('zlib') && @gzinflate($value) !== false ? gzinflate($value) : null,
            'save' => static fn (string $value): string => extension_loaded('zlib') ? gzdeflate($value) : $value,
        ],
    ],
    // Formatting functions, it runs after decoding
    'formatters' => [
        static function (string $value): ?string {
            if (@unserialize($value, ['allowed_classes' => false]) !== false) {
                $unserialized_value = unserialize($value, ['allowed_classes' => false]);

                if (is_array($unserialized_value)) {
                    try {
                        return json_encode($unserialized_value, JSON_THROW_ON_ERROR);
                    } catch (JsonException $e) {
                        return $e->getMessage();
                    }
                }
            }

            return null;
        },
    ],
];
  1. Run dengan docker compose up -d
redis-commander

redis-commander

redis-commander

redis-commander


phpCacheAdmin atau redis-commander?

Biar lebih mudah dan cepat di mengerti, berikut perbandingan keduanya:

phpCacheAdmin redis-commander
Deployment mudah Deployment mudah
Ada fitur search Tidak ada fitur search
Tidak ada redis-cli Ada fitur redis-cli
Bisa hapus multiple key lewati menu Tidak bisa hapus multiple key (hanya bisa tapi lewat redis-cli)
List key muncul semua, walaupun lama Cepat saat list key, tapi tidak muncul semua di list
Lebih mudah digunakan oleh orang non IT Mudah, tapi banyak fitur yang tidak ada yang dibutuhkan oleh orang non IT
Tidak ada user page Tidak ada user page
Config server redis via file config.php Config server redis via menu di web

Untuk harden config dan login dikeduanya, kamu bisa lihat di tutorial saya yang lain setup basic-auth dan nginx-ultimate-bad-bot-blocker


Jika kamu merasa tulisan ini bermanfaat & membantu kamu, kamu bisa berdonasi lewat saweria

If you feel this website help you, you can donate at saweria